how to write query to get today's date data in SQL server
?
select * from tbl_name where date = <Todays_date>
MySQL SYSDATE() Function The SYSDATE() function returns the current date and time.
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).
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With