Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Calculating Time (DateAdd) (Access 2003)

    I have a field on a form that calculates the time based on your selection of the time difference in a combo box as follows:

    =DateAdd("h",[cmbo_meetinglength],[time_start])

    This works fine. However, the combo box includes fractions of time as well (eg: 1.5 for one and a half hours). The DateAdd function doesn't like this. How can I get the calculation field to calculate fractions of time, like half an hour?

    Thanks,

    JoeK

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Calculating Time (DateAdd) (Access 2003)

    How about using:


    Format([time_start]-1-[cmbo_meetinglength],"Short Time")

    This will work for even when the time ends the next day with a 24 hour period
    Jerry

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Calculating Time (DateAdd) (Access 2003)

    Sorry. I'm not sure where you mean to put this expression - in the end-time control on the form? It didn't seem to work for me...

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Calculating Time (DateAdd) (Access 2003)

    Try this:
    =[time_start]+[cmbo_meetinglength]/24
    as the control source for the end-time control.
    Regards
    John



  5. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Calculating Time (DateAdd) (Access 2003)

    My apologies, I have this formula in a query...buuuut if you create an unbound field in your form and place

    =Format([time_start]-1-[cmbo_meetinglength],"Short Time")

    In Data | Control Source for the properties of the form, it will work
    Jerry

  6. #6
    2 Star Lounger
    Join Date
    May 2002
    Location
    Jerusalem, Israel
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Calculating Time (DateAdd) (Access 2003)

    That worked.

    Thanks!

    JoeK

Posting Permissions

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