date between two dates sql code example

Example 1: sql check if date is between 2 dates

SELECT startDate, endDate
FROM YourTable
WHERE '2012-10-25' between startDate and endDate

Example 2: sql BETWEEN

/*the BETWEEN operator is used to filter the result set within 
a certain range. the values can be numbers, texts or dates */
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

Example 3: sql between

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

Example 4: difference in dates sql

SELECT (END_DATE - START_DATE) Days-Total FROM MyTable
/*this works for oracle sql*/

Example 5: SQL query to select data between two dates

SELECT * FROM  [table] 
WHERE [time] >='2014-04-08 23:53:00.000' AND [time] <= '2014-04-08 23:58:00.000'

Tags:

Sql Example