Views help - Date in Where clause

  • Thread starter Thread starter Vlad Pronin
  • Start date Start date
V

Vlad Pronin

Hi!
I have table with [EntryDate] field in it.
I have problem creating where clause with selection for last 30 days
starting from today's day.

Any help appreciated.

Thanks
 
You can do :

WHERE dt BETWEEN DATEADD(d, -30, CURRENT_TIMESTAMP)
AND CURRENT_TIMESTAMP
 
GETDATE() and CURRENT_TIMESTAMP both return date+time, FYI. So subtracting
30 may only give you partial days, depending on when you run the query.
 
What if 'entrydate' could be either positive or negative number? Any way
of doing this easily in the WHERE clause?

Thanks in advance...

-BB

David Portas said:
...
WHERE entrydate >= DATEADD(DAY,-29,CONVERT(CHAR(8),CURRENT_TIMESTAMP,112))

--
David Portas
------------
Please reply only to the newsgroup
--

Vlad Pronin said:
Hi!
I have table with [EntryDate] field in it.
I have problem creating where clause with selection for last 30 days
starting from today's day.

Any help appreciated.

Thanks
 
Back
Top