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 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply