Jump to content

GUICtrlRead(GUICtrlCreateDate) to stirng


Recommended Posts

im try to convert a time to a number so i can round it.

IE:

starttime: 4:00pm

endtime: 5:15pm

totaltime: 1.25

so to do this, i need to convert a time into a string that i can use the "round" function to do this. just trying to get some input on the best way to doit. thanks for the help.

$labelStartTime = GUICtrlCreateLabel("start time", 265, 110.5)
    $timeStartTime = GUICtrlCreateDate("", 265, 133, 90, -1, $DTS_TIMEFORMAT)
        $formatStartTime = GUICtrlGetHandle($timeStartTime)
        _GUICtrlDTP_SetFormat($formatStartTime, "hh:mm  tt")
    $labelEndTime = GUICtrlCreateLabel("end time", 265, 175)
    $timeEndTime = GUICtrlCreateDate("", 265, 197.5, 90, -1, $DTS_TIMEFORMAT)
        $formatEndTime = GUICtrlGetHandle($timeEndTime)
        _GUICtrlDTP_SetFormat($formatEndTime, "hh:mm  tt")
    $labelTotalTime = GUICtrlCreateLabel("total time", 265, 242.5)
    $timeTotalTime = GUICtrlCreateInput("", 265, 265, 90, -1, $ES_READONLY) 
        Case $buttonCalcTotalTime
             $varStartTime = GUICtrlRead($timeStartTime)
             $varEndTIme = GUICtrlRead($timeEndTime)
             $varTotalTime = _DateDiff('h', _NowCalcDate() & " " & $varStartTime, _NowCalcDate() & " " & $varEndTime)
             GUICtrlSetData($timeTotalTime, $varTotalTime)
Link to comment
Share on other sites

i solved it myself, can't beleive it was so hard, all i needed was the datediff to calculate minutes inplace of hours, and divide by 60

replace

$varTotalTime = _DateDiff('h', _NowCalcDate() & " " & $varStartTime, _NowCalcDate() & " " & $varEndTime)
GUICtrlSetData($timeTotalTime, $varTotalTime)

with, (sorry to be so stupid to have not figured this out.)

$varTotalTime = _DateDiff('n', _NowCalcDate() & " " & $varStartTime, _NowCalcDate() & " " & $varEndTime)
GUICtrlSetData($timeTotalTime, $varTotalTime / 60)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...