If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Converting time from number
Hi,
I was asked to develop a telephone log tracking in access. The base table is linked to a DBF of the telephoning software. I have a problem displaying the DURATION and TIME (both save in numeric) into the correct format TIME = 54120 How to display into proper time format (eg: 00:00) SF |
#2
|
|||
|
|||
Converting time from number
SF wrote:
Hi, I was asked to develop a telephone log tracking in access. The base table is linked to a DBF of the telephoning software. I have a problem displaying the DURATION and TIME (both save in numeric) into the correct format TIME = 54120 How to display into proper time format (eg: 00:00) SF For TIME, in order to change the total number of seconds from midnight into military time, try: Public Function SecToMilitary(lngNumberOfSeconds) As String SecToMilitary = Format(lngNumberOfSeconds \ 3600, "00") & ":" _ & Format(lngNumberOfSeconds \ 60, "00") End Function or (to add tenths of a minute): Public Function SecToMilitary(lngNumberOfSeconds) As String SecToMilitary = Format(lngNumberOfSeconds \ 3600, "00") & ":" _ & Format(lngNumberOfSeconds \ 60 _ + Round((lngNumberOfSeconds Mod 60) / 60, 1), "00.0") End Function Note: It wouldn't hurt to make sure lngNumberOfSeconds is less than the number of seconds in a day (60 * 60 * 24 = 86400). For DURATION, see: http://groups.google.com/group/micro...d17d7fcefc3ae0 James A. Fortune |
#3
|
|||
|
|||
Converting time from number
On Wed, 08 Jul 2009 22:17:16 -0400, "James A. Fortune"
wrote: For TIME, in order to change the total number of seconds from midnight into military time, try: Public Function SecToMilitary(lngNumberOfSeconds) As String SecToMilitary = Format(lngNumberOfSeconds \ 3600, "00") & ":" _ & Format(lngNumberOfSeconds \ 60, "00") End Function Or more simply, DateAdd("s", lngNumberOfSeconds, datefield) -- John W. Vinson [MVP] |
#4
|
|||
|
|||
Converting time from number
John W. Vinson wrote:
On Wed, 08 Jul 2009 22:17:16 -0400, "James A. Fortune" wrote: For TIME, in order to change the total number of seconds from midnight into military time, try: Public Function SecToMilitary(lngNumberOfSeconds) As String SecToMilitary = Format(lngNumberOfSeconds \ 3600, "00") & ":" _ & Format(lngNumberOfSeconds \ 60, "00") End Function Or more simply, DateAdd("s", lngNumberOfSeconds, datefield) I agree that's simpler, but you still need to use the "hh:nn" format if you want military time. Maybe something like: Format(DateAdd("s", lngNumberOfSeconds, CDate(0)), "hh:nn") or the same thing with some other date value since the date part will not show anyway. James A. Fortune |
#5
|
|||
|
|||
Converting time from number
On Thu, 09 Jul 2009 18:35:34 -0400, "James A. Fortune"
wrote: I agree that's simpler, but you still need to use the "hh:nn" format if you want military time. Maybe something like: Format(DateAdd("s", lngNumberOfSeconds, CDate(0)), "hh:nn") Sure, or - my preference - just set the Format property of the form or report textbox. -- John W. Vinson [MVP] |
#6
|
|||
|
|||
Converting time from number
John W. Vinson wrote:
On Thu, 09 Jul 2009 18:35:34 -0400, "James A. Fortune" wrote: I agree that's simpler, but you still need to use the "hh:nn" format if you want military time. Maybe something like: Format(DateAdd("s", lngNumberOfSeconds, CDate(0)), "hh:nn") Sure, or - my preference - just set the Format property of the form or report textbox. Good idea. That's very clean. James A. Fortune |
Thread Tools | |
Display Modes | |
|
|