set default time, add time in date, default timestamp, time stamp
Another story :)
some time we need to add timestamp along with the date, or we need to replace existing timestamp with custom timestamp
Yes this is doable and it is very easy.
Here i am going to show a example from AdventuresWorks database, object will be user person.person and fieldname is createdDate.
1. I am converting first datetime to date only
2. Append date with default timestamp
This will work on both either on date field or on datetime field
select cast(createddate as date) ,DATEADD(day, DATEDIFF(day, 0, cast(createddate as date) ), '11:00:00.000') from [Person].[Person]
Another story :)
some time we need to add timestamp along with the date, or we need to replace existing timestamp with custom timestamp
Yes this is doable and it is very easy.
Here i am going to show a example from AdventuresWorks database, object will be user person.person and fieldname is createdDate.
1. I am converting first datetime to date only
2. Append date with default timestamp
This will work on both either on date field or on datetime field
select cast(createddate as date) ,DATEADD(day, DATEDIFF(day, 0, cast(createddate as date) ), '11:00:00.000') from [Person].[Person]
No comments:
Post a Comment