Views help - Date in Where clause

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
 
A

Anith Sen

You can do :

WHERE dt BETWEEN DATEADD(d, -30, CURRENT_TIMESTAMP)
AND CURRENT_TIMESTAMP
 
D

David Portas

....
WHERE entrydate >= DATEADD(DAY,-29,CONVERT(CHAR(8),CURRENT_TIMESTAMP,112))
 
D

dh

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.
 
B

Brian Burgess

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top