Link to home
Start Free TrialLog in
Avatar of newone2011
newone2011

asked on

MS SQL Query to search between dates

I want to write a query where I can serarch from a table based on date column, however I do not want pass any date.  THe requirement is to always search today's data or yesteday's date betweenn 0000 and 2359 hrs.
For example:

select * from Table1 where entryDate>=todays date 0000 and <todays's date 2359.

for todays's date can I use sysdate or something  like that instead of passing a value from the program ?
Avatar of santhimurthyd
santhimurthyd
Flag of United States of America image

Yes you can use

select * from Table1 where entryDate>=getdate() and entryDate<getdate()
SOLUTION
Avatar of tim_cs
tim_cs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
dqmq,

Returns the same thing, just in a different way.
take alook into this link to play around Datetime function in SQL and MYSQL

http://www.w3schools.com/sql/sql_dates.asp
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of newone2011
newone2011

ASKER

Thanks guys let me test
no