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.

  • That's a lot of reading. have you considered something more general for SQL first?
    – gbn
    Mar 26, 2012 at 14:13
  • The correct notation for an ANSI date literal is DATE '1970-01-01'. Note the single quotes around the actual date.
    – user1822
    Mar 26, 2012 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, 2012 at 14:20

1 Answer 1


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'
  • Oracle would accept either of these as well assuming the proper NLS_DATE_FORMAT. Mar 26, 2012 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, 2012 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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