Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
joebuzz83
Starting Member
16 Posts |
Posted - 2012-01-06 : 12:03:48
|
| Hi all,I am trying (and trying and trying....) to manipulate a date within a complex script. I am trying to do the following within my initial select statement:1. subtract 16 days from a datetime column2. get the result of the new datetime and minus that from todays day3. extract only the days from the final datetimeSo if I have an intial datetime of 2011-01-17 23:52:69.999, I will need to subtract 16 days resulting in a value of 2011-01-01 23:52:69.999then I will need to take that value and subtract it from todays date,then i will need to extract how many days have passed from the datetime to today.I was trying to manipulate the datetime using this:, (case when t.reason_codes_display_only!='' then (select datediff(day, (DATEadd(DAY, -16, (Convert(varchar,convert(datetime,t.tran_date),101), GETDATE()))))) else '' end) as 'Days from Denial Date'--13Would one of you kind folks please help me out? I'm lost. |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-01-06 : 12:34:41
|
Would this work?DATEDIFF(dd,DATEADD(dd,-16,t.tran_date),GETDATE()) |
 |
|
|
joebuzz83
Starting Member
16 Posts |
Posted - 2012-01-06 : 13:26:19
|
| You are great! Thanks..... I tried that form as well, but it wouldn't work. i must have had something wrong and didn't notice. Thanks so much! |
 |
|
|
|
|
|
|
|