there is always something to develop
How to replace date part in datetime variable
The simpliest way of replacing the date in datetime variable without changeing the actual time is to do a trick as bellow:
declare @cDateTime datetime; declare @cYear integer; declare @cMonth integer; declare @cDay integer; set @cDateTime=getdate(); set @cYear = 2009; set @cMonth = 1; set @cDay = 1; select (@cDateTime- dateadd(dd,0, datediff(dd,0,@cDateTime)))+ dateadd(month,((@cYear-1900)*12)+@cMonth-1,@cDay-1);
See also
Comments
"Life is a journey...not a destination. Enjoy the trip! "
You are 4950 reader
since 25th August 2009
Yes | 0 | |
No | 100.0% |
18 |