Use the VBScript Docs to learn about conversion functions
like CInt(), mathematical/number manipulating functions
like Int(), Fix(), Round(), and their differences.
Demo code:
Dim nTest
For Each nTest In Array( _
60, 3600, 89493, 90, 5400 _
)
Dim nTotalSeconds
Dim nHours, nMinutes, nSeconds
WScript.Echo nTest
nTotalSeconds = nTest
nHours = CInt( nTotalSeconds / 3600 )
nTotalSeconds = nTotalSeconds - (3600 * nHours)
nMinutes = CInt( nTotalSeconds / 60 )
nSeconds = nTotalSeconds - (60 * nMinutes)
WScript.Echo Join( Array( "wrong CInt:", nHours, nMinutes, nSeconds ) )
nTotalSeconds = nTest
nHours = Int( nTotalSeconds / 3600 )
nTotalSeconds = nTotalSeconds - (3600 * nHours)
nMinutes = Int( nTotalSeconds / 60 )
nSeconds = nTotalSeconds - (60 * nMinutes)
WScript.Echo Join( Array( "Int: ", nHours, nMinutes, nSeconds ) )
nTotalSeconds = nTest
nHours = nTotalSeconds \ 3600
nTotalSeconds = nTotalSeconds Mod 3600
nMinutes = nTotalSeconds \ 60
nSeconds = nTotalSeconds Mod 60
WScript.Echo Join( Array( "\ Mod: ", nHours, nMinutes, nSeconds ) )
WScript.Echo
Next
output:
---------------------------------
60
wrong CInt: 0 1 0
Int: 0 1 0
\ Mod: 0 1 0
3600
wrong CInt: 1 0 0
Int: 1 0 0
\ Mod: 1 0 0
89493
wrong CInt: 25 -8 -27
Int: 24 51 33
\ Mod: 24 51 33
90
wrong CInt: 0 2 -30
Int: 0 1 30
\ Mod: 0 1 30
5400
wrong CInt: 2 -30 0
Int: 1 30 0
\ Mod: 1 30 0
=================================