Results 1 to 3 of 3

Thread: DateDiff

  1. #1
    Join Date
    Mar 2011

    Unanswered: DateDiff

    I have an expression based on 2 fields on a form EventStartTimeDay1 and EventEnd Day1 which I want to show the hours only I have:
    =DateDiff("h",[EventStartDay1],[EventEndDay1]) but this shows 00:00.. What am I doing wrong please

    I also want to be able to add another two fields similar based on day2 and add both sets together to show the result.

  2. #2
    Join Date
    Mar 2011
    I have made a query based on this instead but when I run the query I get a box asking for a parameter for EventStartDay1 and EndDay1. If I enter a number say 1 (I presume it is asking for an eventID as I have many events it runs the query but shows all the events and the hoursDay1 field I have created in my query shows 0 hours. The query is HoursDay1: [EventEndDay1]-[EventStartDay1]. What is going on anyone.

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    check that EventEndDay1 and EventStartDay1 are actually the names of the columns in your table given you have enclosed them in [ ], they coudl possibly be control names I suppose, but not sure about that.

    the fact that you are being requested to enter values suggests to me they are not.

    I'm a litle leery seeing a column called EventEndDay1, which suggests there may be a EventEndDay2...n

    also seeign a column called EventStartTimeDay suggests you may not be clear as to how Access / JET stroes dates/times. like mosts db systems date time values are stored as a single entity/ the actual representation is platform/db specific. I JET's case its the number of ticks since a becnhmark date IIRC 01 Jan 1900, which is stored as an integer. the time element is stroed as the number of seconds since midnight, stored as decimals.

    so .25 is six hours, .5 is 12 hours 1/86400 is one second (or if you prefer 1/(60*60*24))

    using datediff is the correct way to date/time arithmetic but you can just as easily subtract one date from the other, althoughits a clarty way of dong it, Access/Jet allows you to do so as the actual mechanism of storage is a number.

    so fdirst off chaeck to findout why the values you thing are date time are not.... my guess is they are either missplet of they are not oin the current scope of the project
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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