What's the SQL function for timestamp manipulation?
Posted
by
Eric Leroy
on Stack Overflow
See other posts from Stack Overflow
or by Eric Leroy
Published on 2012-10-11T03:34:24Z
Indexed on
2012/10/11
3:37 UTC
Read the original article
Hit count: 209
sql
|sql-server
I'm new to SQL and the time functions are different than mySQL so I'm having a terrible time finding a good site reference with USEFUL timestamp queries.
I'm not able to locate the correct way of doing this query in SQL:
Id Timestamp
-----------------------------------
1145744 2012-10-10 18:15:11.500
1145743 2012-10-10 18:15:11.313
1145742 2012-10-10 18:15:11.313
1145741 2012-10-10 18:15:11.253
1145740 2012-10-10 18:15:11.190
1145739 2012-10-10 18:15:11.190
1145738 2012-10-10 18:15:11.127
1145737 2012-10-10 18:15:11.067
1145736 2012-10-10 18:15:11.063
1145735 2012-10-10 18:15:10.940
1145734 2012-10-10 18:15:10.817
SELECT * from table WHERE Timestamp ... RANGE
I need the range of 2 timestamps so I can select rows by the following parameters:
- second range
- minute range
- hour range
- day range
- week range
- month range
- year range
Is there one function to put in 2 timestamps and get the range? or is this a mix of functions I need?
Any good site references would be greatly appriceated. MSDN site isn't helping me isolate the proper way of doing this. I've been searching for about an hour trying to get the last day from 1:30PM to 1:30PM today.
© Stack Overflow or respective owner