how to transform string in date / time - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# how to transform string in date / time

Posts: 61Member
I'm creating a script that an admin have to set the interval of minutes to choose . Like 2 by 2, 3 by 3 and so on..

I decided to create a field called "hour" and a field called "minutes" as a string format

In this script, the user have to select the hour and minutes that he started to do a task, and the hour and minutes that he finalized the task, and a briefing of he did in that time.

I have to make a math expression to calculate how much hours he worked in the task. If it were data/time field , it would be very easy to do it.. but they are string fields.. does anyone has any suggestion ??

• Posts: 65Member
: I'm creating a script that an admin have to set the interval of minutes to choose . Like 2 by 2, 3 by 3 and so on..
:
: I decided to create a field called "hour" and a field called "minutes" as a string format
:
: In this script, the user have to select the hour and minutes that he started to do a task, and the hour and minutes that he finalized the task, and a briefing of he did in that time.
:
: I have to make a math expression to calculate how much hours he worked in the task. If it were data/time field , it would be very easy to do it.. but they are string fields.. does anyone has any suggestion ??
:
:
LIKE THIS OR???
<%
Function CallTimeSeconds(StartTime,EndTime)
StartHour = Hour(StartTime)
StartMin = Minute(StartTime)
StartSec = Second(StartTime)
EndHour = Hour(EndTime)
EndMin = Minute(EndTime)
EndSec = Second(EndTime)
StartingSeconds = (StartSec + (StartMin * 60) + ((StartHour * 60)*60))
EndingSeconds = (EndSec + (EndMin * 60) + ((EndHour * 60)*60))
CallTimeSeconds = EndingSeconds - StartingSeconds
End Function

IF Request.Form("Btn")<>"" THEN
HStart=Request.Form("HStart")
MStart=Request.Form("MStart")
HEnd=Request.Form("HEnd")
MEnd=Request.Form("MEnd")
StartTime=HStart&":"&MStart&":00"
EndTime= HEnd&":"&MEnd&":00"

S=CallTimeSeconds(StartTime,EndTime)
M=S/60
H=M/60

Response.write S&" s
"
Response.write M&" minutes
"
Response.write H&" hour
"
END IF
%>

 HStart MinStart 000102030405060708091011121314151617181920212223 000510152025303540455055 HEnd MinEnd 000102030405060708091011121314151617181920212223 000510152025303540455055

/haxme

• Posts: 61Member
[b][red]This message was edited by marcoskn1 at 2003-6-14 17:24:4[/red][/b][hr]
Exactly !! Thanks a lot !!

Another question... some hours the result is like: 1,236777 hours..

how can I make like 1 hour ?

another thing..
when the difference is like 10 hours, it returns sth like 10 hours, 540 minutes..

i'd like sth like 10 hours 0 mins

: : I'm creating a script that an admin have to set the interval of minutes to choose . Like 2 by 2, 3 by 3 and so on..
: :
: : I decided to create a field called "hour" and a field called "minutes" as a string format
: :
: : In this script, the user have to select the hour and minutes that he started to do a task, and the hour and minutes that he finalized the task, and a briefing of he did in that time.
: :
: : I have to make a math expression to calculate how much hours he worked in the task. If it were data/time field , it would be very easy to do it.. but they are string fields.. does anyone has any suggestion ??
: :
: :
: LIKE THIS OR???
: <%
: Function CallTimeSeconds(StartTime,EndTime)
: StartHour = Hour(StartTime)
: StartMin = Minute(StartTime)
: StartSec = Second(StartTime)
: EndHour = Hour(EndTime)
: EndMin = Minute(EndTime)
: EndSec = Second(EndTime)
: StartingSeconds = (StartSec + (StartMin * 60) + ((StartHour * 60)*60))
: EndingSeconds = (EndSec + (EndMin * 60) + ((EndHour * 60)*60))
: CallTimeSeconds = EndingSeconds - StartingSeconds
: End Function
:
:
:
: IF Request.Form("Btn")<>"" THEN
: HStart=Request.Form("HStart")
: MStart=Request.Form("MStart")
: HEnd=Request.Form("HEnd")
: MEnd=Request.Form("MEnd")
: StartTime=HStart&":"&MStart&":00"
: EndTime= HEnd&":"&MEnd&":00"
:
: S=CallTimeSeconds(StartTime,EndTime)
: M=S/60
: H=M/60
:
: Response.write S&" s"
: Response.write M&" minutes"
: Response.write H&" hour"
: END IF
: %>
:
:
:

:
: : : :
: : : :
: : : :
: : : : : :  HStart MinStart : 00: 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: : : 00: 05: 10: 15: 20: 25: 30: 35: 40: 45: 50: 55: HEnd MinEnd : 00: 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: : : 00: 05: 10: 15: 20: 25: 30: 35: 40: 45: 50: 55:

:
:
: /haxme
:
:
:
:

• Posts: 65Member
: [b][red]This message was edited by marcoskn1 at 2003-6-14 17:24:4[/red][/b][hr]
: Exactly !! Thanks a lot !!
:
: Another question... some hours the result is like: 1,236777 hours..
:
: how can I make like 1 hour ?
:

<%=FormatNumber(1,236777 , 1)%>

: another thing..
: when the difference is like 10 hours, it returns sth like 10 hours, 540 minutes..
:
: i'd like sth like 10 hours 0 mins
:

IF Request.Form("Btn")<>"" THEN
HStart=Request.Form("HStart")
MStart=Request.Form("MStart")
HEnd=Request.Form("HEnd")
MEnd=Request.Form("MEnd")
StartTime=HStart&":"&MStart&":00"
EndTime= HEnd&":"&MEnd&":00"

S=CallTimeSeconds(StartTime,EndTime)
M=S/60
H=M/60
HPart=INT(H)
MinutesLeft=M-(60*HPart)
'Response.write S&" s
"
'Response.write M&" minutes
"
Response.write HPart&" hour and " &MinutesLeft& " minutes
"

END IF

/haxme

:
: : : I'm creating a script that an admin have to set the interval of minutes to choose . Like 2 by 2, 3 by 3 and so on..
: : :
: : : I decided to create a field called "hour" and a field called "minutes" as a string format
: : :
: : : In this script, the user have to select the hour and minutes that he started to do a task, and the hour and minutes that he finalized the task, and a briefing of he did in that time.
: : :
: : : I have to make a math expression to calculate how much hours he worked in the task. If it were data/time field , it would be very easy to do it.. but they are string fields.. does anyone has any suggestion ??
: : :
: : :
: : LIKE THIS OR???
: : <%
: : Function CallTimeSeconds(StartTime,EndTime)
: : StartHour = Hour(StartTime)
: : StartMin = Minute(StartTime)
: : StartSec = Second(StartTime)
: : EndHour = Hour(EndTime)
: : EndMin = Minute(EndTime)
: : EndSec = Second(EndTime)
: : StartingSeconds = (StartSec + (StartMin * 60) + ((StartHour * 60)*60))
: : EndingSeconds = (EndSec + (EndMin * 60) + ((EndHour * 60)*60))
: : CallTimeSeconds = EndingSeconds - StartingSeconds
: : End Function
: :
: :
: :
: : IF Request.Form("Btn")<>"" THEN
: : HStart=Request.Form("HStart")
: : MStart=Request.Form("MStart")
: : HEnd=Request.Form("HEnd")
: : MEnd=Request.Form("MEnd")
: : StartTime=HStart&":"&MStart&":00"
: : EndTime= HEnd&":"&MEnd&":00"
: :
: : S=CallTimeSeconds(StartTime,EndTime)
: : M=S/60
: : H=M/60
: :
: : Response.write S&" s"
: : Response.write M&" minutes"
: : Response.write H&" hour"
: : END IF
: : %>
: :
: :
: :

: :
: : : : : : : :
: : : : : : : :
: : : : : : : :
: : : : : : : : : : : :  HStart MinStart : : 00: : 01: : 02: : 03: : 04: : 05: : 06: : 07: : 08: : 09: : 10: : 11: : 12: : 13: : 14: : 15: : 16: : 17: : 18: : 19: : 20: : 21: : 22: : 23: : : : : : 00: : 05: : 10: : 15: : 20: : 25: : 30: : 35: : 40: : 45: : 50: : 55: : HEnd MinEnd : : 00: : 01: : 02: : 03: : 04: : 05: : 06: : 07: : 08: : 09: : 10: : 11: : 12: : 13: : 14: : 15: : 16: : 17: : 18: : 19: : 20: : 21: : 22: : 23: : : : : : 00: : 05: : 10: : 15: : 20: : 25: : 30: : 35: : 40: : 45: : 50: : 55: :

: :
: :
: : /haxme
: :
: :
: :
: :
:
:
:
: