Query Data based on functions e.g GETDATE()

  • Hi Gurus

    I have a table that have a datetime column, I want to return data based on datetime on previous month.

    e.g

    SELECT a,b

    WHERE [date & time] >= ' 2011-09-03 00:00:00 AND [date & time] <= '2011-09-03 23:59:59'

    My problem is i want a function that will return the date and time as above based on GETDATE() function, I can work out the query to access the previous month by using DATEADD(M,-1,GETDATE()), but it also gives me the current time.

    Is the a way i can set my time to be fixed on both dates. We usually set the date & time in our software when running the report, but now i want to use ssis to extract & upload to a ftp server, instead of us running it manually.Or is the a way to do the above in SSRS??

    Thanks in Advanced

    Fortune (South Africa)

  • SELECT DATEADD(D, 0, DATEDIFF(D, 0, GETDATE()))

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply