Time Duration Problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CDF

    Time Duration Problems

    In one of my tables, I have a field that has time durations in it.
    The field is currently in text format. Is there a way that I can
    convert this field into a format where I can SUM the durations? Help
    is appreciated!

    Thanks,

    Corey
  • Allen Browne

    #2
    Re: Time Duration Problems

    Text would be the least useful/reliable field type for this data.

    Consider replacing it with a Number (Long Integer) to store the number of
    whole minutes (or seconds). It's easy to sum the values:
    DSum("Minutes", "MyTable")
    or display as hours:minutes:
    =[Minutes] \ 60 & Format([Minutes] Mod 60, "\:00")

    For data entry, you can provide 2 text boxes where the user enters the hours
    and minutes, and use the AfterUpdate event of these text boxes to write the
    number of minutes to the hidden field:
    Me.Minutes = Nz(60 * Me.txtHours,0) + Nz(Me.txtMinute s, 0)

    Some people try using the Date/Time field for storing durations. That's
    feasible, but for summing values greater than 24 hours you have to convert
    to minutes and use the display method shown above. To convert to minutes:
    DateDiff("n", #0:00#, [MyField])

    If you wish to continue with the Text type, and are sure there are no
    invalid entries, you could combine these various data casting methods. A
    calculated field of minutes to sum would be:
    DateDiff("n", #0:00#, CDate([MyField]))

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html

    "CDF" <cflemi05@sprin tspectrum.com> wrote in message
    news:5cbef661.0 309221148.7ccf7 3ad@posting.goo gle.com...[color=blue]
    > In one of my tables, I have a field that has time durations in it.
    > The field is currently in text format. Is there a way that I can
    > convert this field into a format where I can SUM the durations? Help
    > is appreciated!
    >
    > Thanks,
    >
    > Corey[/color]


    Comment

    • Pieter Linden

      #3
      Re: Time Duration Problems

      cflemi05@sprint spectrum.com (CDF) wrote in message news:<5cbef661. 0309221148.7ccf 73ad@posting.go ogle.com>...[color=blue]
      > In one of my tables, I have a field that has time durations in it.
      > The field is currently in text format. Is there a way that I can
      > convert this field into a format where I can SUM the durations? Help
      > is appreciated!
      >
      > Thanks,
      >
      > Corey[/color]

      you should be able to use CDate to convert the thing to a time... and
      then go from there... either that or parse it and turn it into
      minutes...

      Comment

      Working...