Date formatting for calculations

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn29316
    New Member
    • Feb 2007
    • 33

    Date formatting for calculations

    Hi,

    I've used a form to capture the requesters date range specifications for a set of queries forever and never cared that it took the short date entered by the requester and changed it to a number when it stored the date for later use.

    Now I'm trying to subtract that number from a date supplied from a system database, which is in short date format, and the output looks like a short date instead of a number.

    Can someone help me get a result that looks like the number of days between 2 dates instead of getting something that looks like a date?

    Thanks,
    Shawn
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Originally posted by Shawn29316
    Hi,

    I've used a form to capture the requesters date range specifications for a set of queries forever and never cared that it took the short date entered by the requester and changed it to a number when it stored the date for later use.

    Now I'm trying to subtract that number from a date supplied from a system database, which is in short date format, and the output looks like a short date instead of a number.

    Can someone help me get a result that looks like the number of days between 2 dates instead of getting something that looks like a date?

    Thanks,
    Shawn
    One way is to use the DateDiff function. See this link:

    This MSAccess tutorial explains how to use the Access DateDiff function with syntax and examples. The Microsoft Access DateDiff function returns the difference between two date values, based on the interval specified.


    Dim x as integer ' number of days

    x = DateDiff("d", [Date1] , [Date2])

    Comment

    Working...