Results 1 to 2 of 2
Thread: SQL Reporting Services 2005
2008-02-22, 10:24 #1
- Join Date
- Aug 2006
- Gtr London, England
- Thanked 0 Times in 0 Posts
SQL Reporting Services 2005
Im currently putting together a report where it is necessary to compare the dates between two columns and put the difference in a third column in the layout screen.
Im aware that DateDiff will compare dates but I cant find any examples where DateDiff compares dates between two different columns within a table.
I assume this is possible??
Any help will be grately appreciated.
2008-02-22, 13:40 #2
- Join Date
- Feb 2002
- A Magic Forest in Deepest, Darkest Kent
- Thanked 1 Time in 1 Post
Re: SQL Reporting Services 2005
If I get this right you just need a SQL statement like so:
select dtinsertdate, cast(getdate()- dtinsertdate as decimal(10,0)) as dtDate
This piece of code just selects the field dtinsertdate and then another field which I have calculated to subtract today's date and the dtinsertdate. The cast function converts it to a number instead of a date.
Similarly if it is just a matter of subtracting two field names it would take this form:
select cast((dtDate1- dtDate2) as decimal(10,0)) as dtDate