What's the SQL function for timestamp manipulation?
- by Eric Leroy
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.