Link to home
Create AccountLog in
Avatar of zintech

asked on

Get today's date in SQL Query

I am running a query, and I would like to be able to compare today's date with a field in the database table.  As in

SELECT * FROM table1
WHERE datecolumn <= (SQL query for today's date)
Avatar of pilson66
Flag of Ukraine image

   DATE() returns the date without time
    NOW() returns the current date & time (note we've used the DATE() function in this query to remove the time)
Avatar of Lee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Is this MySQL or SQL Server? You have it in both zones.
select * from table1 where datecolumn <= DATE(NOW());
SELECT * FROM table1
WHERE datecolumn <= getdate()
To compare the date without the time component:

SELECT * FROM table1
WHERE datecolumn <= convert(int,getdate())