How to Retrieve Rows Using TimeStamp Best SQL Query

It is very practical question. Sometimes you need to search DB Tables to get the rows by Timestamp.


Also Read: 32 Complex SQL Queries for Your Next Interview


SQL Query to get rows using Timestamp

Example:

SELECT A, B, C
FROM SAMP_TBL
WHERE
A >=  '1999-01-01 00:00:00.000000'
or...
A <=  '1999-01-01 00:00:00.000000'
or...
A = Current Timestamp - 90 days
or...
A = '1999-01-01 00:00:00.000000'  + 30 days
etc...

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.