Selecting Records from SQL Server Database using a DateTime field - Support

Selecting Records from SQL Server Database using a DateTime field

From Support

Jump to: navigation, search

Listed below is a sample string that selects all records from a database where the date is less than 1/1/2002.

Notice that you should also include the time string when selecting records from a database.

SELECT * FROM NAMEADDR where DATE2 < '01/01/2002 12:00:00AM' 

Listed below is a sample string that selects all records from a database where the date is = 1/1/2002.

Notice that you should also include the time string when selecting records from a database. IN this case, we get all records created between midnight and 11:59PM.

SELECT * FROM NAMEADDR where DATE2 >= '01/01/2002 12:00:00AM'  and  DATE2 <= '01/01/2002 11:59:00PM'
Personal tools