Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to do this in a SQL database

 SELECT * FROM Employee
    WHERE BirthDate BETWEEN DATE 1970-01-01 AND DATE 1970-01-01

The result that was said to from this query is all the employees that are born on 1970-01-01. This query has been taken from the following book Sorry if this question is lacking.

share|improve this question
That's a lot of reading. have you considered something more general for SQL first? – gbn Mar 26 '12 at 14:13
The correct notation for an ANSI date literal is DATE '1970-01-01'. Note the single quotes around the actual date. – a_horse_with_no_name Mar 26 '12 at 14:14
yeah I know it's a lot of reading but I am just skipping through most of it because most of it isn't really interesting on the research I am doing. – mariomario Mar 26 '12 at 14:20
up vote 1 down vote accepted

Some variety of this, depending on RDBMS. SQL Server and MySQL accept date literals like this:

SELECT * FROM Employee
    WHERE BirthDate BETWEEN '1970-01-01' AND '1970-01-01'

SELECT * FROM Employee
    WHERE BirthDate BETWEEN '19700101' AND '19700101'
share|improve this answer
Oracle would accept either of these as well assuming the proper NLS_DATE_FORMAT. – Leigh Riffel Mar 26 '12 at 15:29
Actaully this would only get the people born at midnight unless you are using SQL Server's date data type and not datetime. If you have times associated, you would want date>='1970-01-01' AND date<'1970-01-02' – HLGEM Mar 26 '12 at 17:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.