Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 'DateTime Field' < 'End of Today'

Author  Topic 

webwiredit
Starting Member

5 Posts

Posted - 2009-10-04 : 11:34:14
I'm having problems with this query... I have found several examples but none that seem to work for me... What I am trying to do is pull all records that have datetimes up to the end of the current day... Here's what I have so far... So I somehow need to convert the GETDATE() to something like GETDATE() with the time being 23:59:59


Select * FROM CRM_Notes WHERE
(FlagStatus = 'Requires Follow Up' AND FlagDateTime < GETDATE());

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-04 : 11:42:32
AND FlagDateTime = dateadd(minute,-1,(dateadd(dd,1, datediff(dd,0,getdate()))))


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webwiredit
Starting Member

5 Posts

Posted - 2009-10-04 : 14:03:56
quote:
Originally posted by webfred

AND FlagDateTime = dateadd(minute,-1,(dateadd(dd,1, datediff(dd,0,getdate()))))


No, you're never too old to Yak'n'Roll if you're too young to die.



Sorry, that didn't work
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-04 : 14:10:18
Ah sorry I didn't read proper...

AND FlagDateTime < dateadd(dd,1, datediff(dd,0,getdate()))
should work.
It gives all FlagDateTime which are less than tomorrow 00:00 h


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webwiredit
Starting Member

5 Posts

Posted - 2009-10-04 : 19:03:17
quote:
Originally posted by webfred

Ah sorry I didn't read proper...

AND FlagDateTime < dateadd(dd,1, datediff(dd,0,getdate()))
should work.
It gives all FlagDateTime which are less than tomorrow 00:00 h


No, you're never too old to Yak'n'Roll if you're too young to die.



Thank you very much webfred, worked perfectly!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-05 : 08:40:23
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -