Friday, February 24, 2012

date field

I have a database table that contains a date field.

I don't know how to construct an sql query that returns the record that has the next closest date (in the future) to the actual date.

I know I need to brush up on sql but any help would be greatly appreciated.

Thanks

RamilaSelect Top 1 DateField From YourTable Where DateField > GetDate() Order By DateField

books online (sql server help files) and www.sqlcourse.com

edited: if you want the next day, I'd go with using DateAdd() function to assist in managing the amount of increate you wish to add to the DateField's criteria.

No comments:

Post a Comment