Comparing DatesBy Bill Graziano on 21 August 2000 | Tags: Queries sandy writes "hello team, suppose i were to store a slew of future date/time values in a table.
Ok Sandy, you get bonus points for the omnipotent part. We SQLTeamer's aren't above letting a little flattery affect us :) The function you are looking for is called DATEDIFF. It compares two dates and returns the results in the unit of measure you specify. Your syntax might look something like this:
SELECT foo We want the results in minutes. You can also return it in years, days, months, hours, seconds, etc. The first date (TableDate) is subtracted from the second date. I used the system date for the second date. This query will tell you how many minutes from TableDate the system date is. If it's within 15 minutes we display the record.
|
- Advertisement - |