Answered by:
Change Value based on Dynamical Object

Question
-
Goal:
The goal is to make the variable with value '2014-06-14 09:00:00.000'
Problem:
The syntax code is created as a dynamical object how do you make it from '2014-06-14 16:20:10.000' into value '2014-06-14 09:00:00.000'?
DECLARE @a datetime = '2014-06-14 16:20:10.000'
Monday, June 16, 2014 9:19 PM
Answers
-
Are you looking for this?
DECLARE @a datetime = '2014-06-14 16:20:10.000' select dateadd(hour,9,convert(datetime,convert(date,@a))) set @a = '2014-06-14 08:20:10.000' select dateadd(hour,9,convert(datetime,convert(date,@a)))
Satheesh
My Blog | How to ask questions in technical forum
- Proposed as answer by Elvis Long Friday, June 20, 2014 5:42 AM
- Marked as answer by Elvis Long Thursday, June 26, 2014 1:26 AM
Tuesday, June 17, 2014 7:02 AM -
DECLARE @a datetime = '2014-06-14 16:20:10.000' -- pass any date value here SELECT DATEADD(dd,DATEDIFF(dd,0,@a),'09:00')
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
- Proposed as answer by Elvis Long Friday, June 20, 2014 5:42 AM
- Marked as answer by Elvis Long Thursday, June 26, 2014 1:26 AM
Tuesday, June 17, 2014 7:08 AM
All replies
-
-
Are you looking for this?
DECLARE @a datetime = '2014-06-14 16:20:10.000' select dateadd(hour,9,convert(datetime,convert(date,@a))) set @a = '2014-06-14 08:20:10.000' select dateadd(hour,9,convert(datetime,convert(date,@a)))
Satheesh
My Blog | How to ask questions in technical forum
- Proposed as answer by Elvis Long Friday, June 20, 2014 5:42 AM
- Marked as answer by Elvis Long Thursday, June 26, 2014 1:26 AM
Tuesday, June 17, 2014 7:02 AM -
DECLARE @a datetime = '2014-06-14 16:20:10.000' -- pass any date value here SELECT DATEADD(dd,DATEDIFF(dd,0,@a),'09:00')
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
- Proposed as answer by Elvis Long Friday, June 20, 2014 5:42 AM
- Marked as answer by Elvis Long Thursday, June 26, 2014 1:26 AM
Tuesday, June 17, 2014 7:08 AM