Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: working with time and dates


Message #1 by "ivan matema" <ivanmatema@m...> on Thu, 21 Nov 2002 14:04:30
some date and time arithmetic. could anyone kindly assist with the getting 
of total hours between2 time periods.
i have 4 textboxes:
1-todays date
2-current time
3-another date, say the previous day
4-the previous day's time

I need to get the total hrs between these two periods.
anyone?
Message #2 by "Mark Liquorman" <Mark@L...> on Thu, 21 Nov 2002 14:21:34
> some date and time arithmetic. could anyone kindly assist with the 
getting 
o> f total hours between2 time periods.
i>  have 4 textboxes:
1> -todays date
2> -current time
3> -another date, say the previous day
4> -the previous day's time

> I need to get the total hrs between these two periods.
a> nyone?
Message #3 by "Mark Liquorman" <Mark@L...> on Thu, 21 Nov 2002 14:30:15
I've got to figure out what I'm doing to post messages before I've started 
to work on them!

Not knowing anything about your controls, I'm going to have to make some 
assumptions.  Basically, you need to add the current date and time 
together then add the old date and time together.  I find the most 
accurate way to find the difference between the 2 in hours is to subtract 
the 2 numbers then multiply the result by 24.  It may be something like 
this (you may not have to use the CDate if your controls are bound to 
Date/Time fields):

HourDiff = ((CDate(currentdate) + CDate(currenttime)) - (Cdate(olddate) + 
CDate(oldtime))) * 24
                   
Message #4 by "Gregory Serrano" <SerranoG@m...> on Thu, 21 Nov 2002 17:39:29
Ivan,

<< I need to get the total hrs between these two periods. >>

Look up help on the DateDiff function.

Greg


Message #5 by "Bob Bedell" <bobbedell15@m...> on Thu, 21 Nov 2002 17:32:31 +0000
'------------------------------------------------------------------
      '  This function calculates the elapsed time between two values and
      '  formats the result in four different ways.
      '
      '  The function accepts interval arguments such as the following:
      '
      '     #5/12/95 6:00:00AM# - #5/11/95 10:00:00PM#
      '
      '     -or-
      '
      '     [End Time]-[Start Time]
'------------------------------------------------------------------
' Called by ElapsedTime(#6/1/1993 8:23:00 PM# - #6/1/1993 8:12:12 AM#)
Function ElapsedTime(interval)
        Dim x
        x = Int(CSng(interval * 24 * 3600)) & " Seconds"
        Debug.Print x
        x = Int(CSng(interval * 24 * 60)) & ":" & Format(interval, "ss") _
           & " Minutes:Seconds"
        Debug.Print x
        x = Int(CSng(interval * 24)) & ":" & Format(interval, "nn:ss") _
           & " Hours:Minutes:Seconds"
        Debug.Print x
        x = Int(CSng(interval)) & " days " & Format(interval, "hh") _
           & " Hours " & Format(interval, "nn") & " Minutes " & _
           Format(interval, "ss") & " Seconds"
        Debug.Print x

End Function



>From: "ivan matema" <ivanmatema@m...>
>Reply-To: "Access" <access@p...>
>To: "Access" <access@p...>
>Subject: [access] working with time and dates
>Date: Thu, 21 Nov 2002 14:04:30
>
>some date and time arithmetic. could anyone kindly assist with the getting
>of total hours between2 time periods.
>i have 4 textboxes:
>1-todays date
>2-current time
>3-another date, say the previous day
>4-the previous day's time
>
>I need to get the total hrs between these two periods.
>anyone?


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail


  Return to Index