Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    SQL Reporting Services 2005

    Hi,

    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.

    Regards.
    Lee

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: SQL Reporting Services 2005

    Lee

    If I get this right you just need a SQL statement like so:

    select dtinsertdate, cast(getdate()- dtinsertdate as decimal(10,0)) as dtDate
    from myTable

    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
    from myTable
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •