date calculation

Results 1 to 3 of 3

Thread: date calculation

  1. #1
    Join Date
    Dec 1969

    Default date calculation

    Ive read all the stuff on date functions nad calculations on this site but i cant find anything that mentions how you would subtract two dates, for example a birthday and the day of death, from data in a database and how many days inbetween, as in this example, lifespan in days. anyone know how or know any tutorials? thanks in advance

  2. #2
    Join Date
    Dec 1969

    Default DateDiff(Interval, Date1, Date2)

    select DateDiff("d", DOB, DOD)as no_of_days from &#060;table&#062;<BR><BR>or <BR><BR>SELECT DATEDIFF(day, DOB, gDOD) AS no_of_days from &#060;table&#062;<BR><BR>access -- sql respectevly

  3. #3
    Join Date
    Dec 1969

    Default DateDiff *IS* in the docs...

    ...but as it turns out if you want a diff in *DAYS* (only) you can easily do that with simple subtraction:<BR><BR> someDay = #4/24/2004#<BR> dayCount = someDay - Date()<BR><BR>If your variable(s) might have a time component in them, just use the DateValue function to get rid of it:<BR><BR> someDay = #4/24/2004 10:15:30 AM#<BR> dayCount = DateValue( someDay ) - Date()<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts