Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Time Value


Message #1 by "Ahmed Khamis" <Ahmed.Khamis@v...> on Fri, 27 Dec 2002 22:34:12 +0200
Good day all,
            Is there is any method to convert the time which is in the format ?HH:MM:ss? into total minutes only
i.e if 3 hours and 15 min then it?s 185 min
 
Best regards, 
 
Ahmed Khamis
Vodafone Egypt
Customer operation
Mob:  xxx-xxx-xxxx
Ext:56-1119
Ahmed.khamis@v...
 


***********************************************
The content of this document is classified as Vodafone Egypt S.A.E. 
Confidential and Proprietary Information. The recipient hereby is 
committed to hold in strict confidence the contents of this 
(e-mail, document, information) and not to disclose to any third party 
without the prior written consent of Vodafone Egypt S.A.E. Recipient 
will be held liable for any unauthorized disclosure.
***********************************************


Message #2 by "Bob Bedell" <bobbedell15@m...> on Sat, 28 Dec 2002 01:51:13 +0000
CInt(((#12:15:00 PM# - #9:00:00 AM#)*24)*60)

The difference is 3.25 hours or 195 minutes.

>From: "Ahmed Khamis" <Ahmed.Khamis@v...>
>Reply-To: "Access" <access@p...>
>To: "Access" <access@p...>
>Subject: [access] Time Value
>Date: Fri, 27 Dec 2002 22:34:12 +0200
>
>Good day all,
>             Is there is any method to convert the time which is in the 
>format ?HH:MM:ss? into total minutes only
>i.e if 3 hours and 15 min then it?s 185 min
>
>Best regards,
>
>Ahmed Khamis
>Vodafone Egypt
>Customer operation
>Mob:  xxx-xxx-xxxx
>Ext:56-1119
>Ahmed.khamis@v...
>
>
>
>***********************************************
>The content of this document is classified as Vodafone Egypt S.A.E.
>Confidential and Proprietary Information. The recipient hereby is
>committed to hold in strict confidence the contents of this
>(e-mail, document, information) and not to disclose to any third party
>without the prior written consent of Vodafone Egypt S.A.E. Recipient
>will be held liable for any unauthorized disclosure.
>***********************************************
>
>
>


_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

Message #3 by "Bob Bedell" <bobbedell15@m...> on Sat, 28 Dec 2002 05:47:20 +0000
Hi Ahmed,

I've been playing with a couple versions of an answer to your question.

Here's using a function:

Function ElapsedMinutes(interval)
        Dim x
        x = Int(CSng(interval * 1440)) & " Minutes"
        Debug.Print x
End Function

Call from the immediate window (Ctrl + G) with:

ElapsedMinutes(#12:15:00 AM# - #9:00:00 AM#)

You could also do this in a query as:
Minutes: ([EndTime]-[StartTime])*1440

In a form or report, you can set the Control Source of a text box to
=([EndTime]-[StartTime])*1440

In both cases, you can set the Format property to display the number of
decimal places you want.

Basically the way this works is that Access stores dates and times in
the form of numbers. The integer part is the number of days since
December 31, 1899 and the fractional part is the time of day (midnight
is .0, 6 AM is .25, noon is .5 etcetera).

If you subtract two dates/times, you get a number that represents a
number of DAYS; to get the number of hours, multiply this by 24; to get
the number of minutes, multiply again by 60. You can check this in
the immediate window by typing:

?(#12:15:00#-#9:00:00#)

You'll get 0.135416666666667 - the difference is a bit more than 13
one-hundredths of a day.

If you type:

?(#12:15:00#-#9:00:00#)*24 you'll get 3.25 (hours)

?(#9:15:00#-#8:00:00#)*24*60 or
?(#9:15:00#-#8:00:00#)*1440 gives you:

75.0000000000001

Hence the need for Int(CSng(interval * 1440)) to return only the
integer portion. Converting to a single first and using function Int
I suppose insures greater precision than:

CInt(((#12:15:00 PM# - #9:00:00 AM#)*24)*60) or
CInt((#12:15:00 PM# - #9:00:00 AM#)*1440)

Hope that clears things up a bit,

Bob


>From: "Bob Bedell" <bobbedell15@m...>
>Reply-To: "Access" <access@p...>
>To: "Access" <access@p...>
>Subject: [access] Re: Time Value
>Date: Sat, 28 Dec 2002 01:51:13 +0000
>
>CInt(((#12:15:00 PM# - #9:00:00 AM#)*24)*60)
>
>The difference is 3.25 hours or 195 minutes.
>
>>From: "Ahmed Khamis" <Ahmed.Khamis@v...>
>>Reply-To: "Access" <access@p...>
>>To: "Access" <access@p...>
>>Subject: [access] Time Value
>>Date: Fri, 27 Dec 2002 22:34:12 +0200
>>
>>Good day all,
>>             Is there is any method to convert the time which is in the 
>>format ?HH:MM:ss? into total minutes only
>>i.e if 3 hours and 15 min then it?s 185 min
>>
>>Best regards,
>>
>>Ahmed Khamis
>>Vodafone Egypt
>>Customer operation
>>Mob:  xxx-xxx-xxxx
>>Ext:56-1119
>>Ahmed.khamis@v...
>>
>>
>>
>>***********************************************
>>The content of this document is classified as Vodafone Egypt S.A.E.
>>Confidential and Proprietary Information. The recipient hereby is
>>committed to hold in strict confidence the contents of this
>>(e-mail, document, information) and not to disclose to any third party
>>without the prior written consent of Vodafone Egypt S.A.E. Recipient
>>will be held liable for any unauthorized disclosure.
>>***********************************************
>>
>>
>>
>
>
>_________________________________________________________________
>Protect your PC - get McAfee.com VirusScan Online 
>http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
>
>---
>Change your mail options at http://p2p.wrox.com/manager.asp or to 
>unsubscribe send a blank email to 


_________________________________________________________________
The new MSN 8: smart spam protection and 3 months FREE*.  
http://join.msn.com/?page=features/junkmail&xAPID=42&PS=47575&PI=7324&DI=7474&SU= 
http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_smartspamprotection_3mf


  Return to Index