SQL Queries: 3 Ways to Get data When DATES Involved

Here’re three ways you can get data with DATEs. These SQL queries are helpful for your SQL projects. Using these, you can get data for Less than a Date, Between two Dates, and Greater than a Date.

1. SQL Query to Get Latest Date

Select item, max(inventory_ date)
from t_table
where inventory_date is < '6/30/2011'

2. SQL Query to retrieve data not more than 6 years from application Date

Select item 
from t_table
where appl_date >= (Currentdate - 6 Years);

3. SQL Query DATE Duration

Select item 
from t_table
WHERE CP.ActionDate
BETWEEN '19/12/2012'
AND '1/17/2013';

Related Posts

Get new content delivered directly to your inbox.

Author: Srini

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