Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get current/Todays date data in sql server

how to write query to get today's date data in SQL server ?

select * from tbl_name where date = <Todays_date>
like image 856
krishna mohan Avatar asked Mar 05 '15 08:03

krishna mohan


People also ask

Which query is used to get the current date in SQL?

MySQL SYSDATE() Function The SYSDATE() function returns the current date and time.

What does NOW () return in SQL?

The NOW() function returns the current date and time. Note: The date and time is returned as "YYYY-MM-DD HH-MM-SS" (string) or as YYYYMMDDHHMMSS. uuuuuu (numeric).


1 Answers

The correct answer will depend of the exact type of your datecolumn. Assuming it is of type Date :

select * from tbl_name 
where datecolumn = cast(getdate() as Date)

If it is DateTime:

select * from tbl_name 
where cast(datecolumn as Date) = cast(getdate() as Date)
like image 137
Mitch Wheat Avatar answered Sep 19 '22 06:09

Mitch Wheat