all groups > sql server mseq > february 2006 >
You're in the

sql server mseq

group:

Date Selection



Date Selection Stan
2/6/2006 6:52:43 AM
sql server mseq: I thought this was simple but...
I have a table with a transdate of data type datetime and I want to select
all transactions either for today or for getdate() minus some value. Looks
to me like the time portion is getting in the way of "where transdate =
(getdate() - 3)". How do I deal with just the date portions of these fields?
Thanks
--
RE: Date Selection Sreejith G
2/6/2006 8:00:28 AM
Hi,

Use DATEADD function...

SELECT DATEADD(hh, -3, getdate())

Thanks,
Sree


[quoted text, click to view]
RE: Date Selection Stan
2/6/2006 1:31:34 PM
Thanks for the response but this still does not work. I know how to get the
system date adjusted to meet my criteria by either using DATADD or just
getdate() - some number. I have to find a way to compare JUST the date
portion to JUST the date portion of the transaction date stored in the table.
--
Stan Gosselin


[quoted text, click to view]
Re: Date Selection Hugo Kornelis
2/7/2006 12:16:38 AM
[quoted text, click to view]

Hi Stan,

To remove the time portion from a datetime column (or variable), use

SELECT DATEADD(day, DATEDIFF(day, 0, CURRENT_TIMESTAMP), 0)


--
Re: Date Selection Stan
2/8/2006 11:38:05 AM
Hugo,
This does the trick! Thanks so much for the response to this and the other
post I made.
Have a good day and thanks again for the help.
--
Stan Gosselin


[quoted text, click to view]
AddThis Social Bookmark Button