January 9, 2007 at 9:36 am
I really need help comparing one date to getDate()
The date stored in my db in the format "2007-01-09 17:17:45.810"
i want to compare it to getDate, and when i say myDate >= getDate(), i get not records, why????
January 9, 2007 at 9:42 am
DECLARE @demo TABLE (MyDate DATETIME NOT NULL PRIMARY KEY CLUSTERED)
INSERT INTO @demo (MyDate)
SELECT DATEADD(D, 1, GETDATE())
UNION ALL
SELECT DATEADD(D, -1, GETDATE())
UNION ALL
SELECT GETDATE()
SELECT MyDate FROM @demo
SELECT MyDate, GetDate() FROM @demo WHERE MyDate >= GetDate()
--Since all that code is executed at the same time, you should get 2 rows with the final select, if you get only 1 it's because the select was made 3+ ms after the insert
--wait 1 second
WAITFOR DELAY '00:00:01'
SELECT MyDate, GetDate() FROM @demo WHERE MyDate >= GetDate()
--Now you should see only 1 row.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy