Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Locating records with a specific time
Message
From
19/11/2014 22:23:56
 
 
To
19/11/2014 21:52:39
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01611170
Message ID:
01611207
Views:
36
>What would be the TSQL syntax that would extract rows where the adddate (a datetime column) was later than 2PM on 11/18/2014?

OK, there are several ways so I'm sure others might reply as well, but here's one way:

I did this for a test row where getdate() returned 11/19 at about 10:20 PM. So my check below is based on 11-19 at 10:00 PM or greater.
CREATE TABLE TestDateTime  ( TestDateTime datetime)

insert into TestDateTime values ( getdate()  )

select * from testdatetime where TestDateTime >= cast('2014-11-19 22:00:00' as datetime)  -- 1 row
select * from testdatetime where TestDateTime < cast('2014-11-19 22:00:00' as datetime)  -- 0 rows
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform