I want to know if there is a way to compare dates in the sql statement with dates that I input into a database and todays date. the datatype that I'm using is smalldatetime.
The statement I used is:
Select Date from Table where Date > 'Today.now'
I get an error
Could this be done or is there another approach?Select Date from Table where Date > getdate()
If you just want to match dates and not times:
Select Date from Table where convert(varchar(10), Date, 101) > convert(varchar(10), getDate(), 101)
Nick
Showing posts with label todays. Show all posts
Showing posts with label todays. Show all posts
Thursday, March 22, 2012
Tuesday, March 20, 2012
Comparing a Date Value in SQL against Todays Date
I have a query that accesses a series of events in a gridview and would like to only show those that are in the future. I am looking to compare the date/time column against today's date in my SQL query.
Any ideas would be great.
Thanks
Orbital
you can use the t-sql function: getdate() in your query
sqlsql
Subscribe to:
Posts (Atom)