Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
if time2 is 20 Hundred Hours: 32 minutes: 17 seconds and time1 = 19 Hundred hours and 59 minutes and 17 seconds. The integer for time2 = 203217 and the integer for time1 = 195917.
The maximum integer size is 2 ^ 31 - 1 = 2,147,483,647.This is because it is a signed 32-bit integer, ie. 32 bit but it uses one bit to store if the number is negative or positive. If you overflow this limit, you'll end up with unexpected results that are likely in the negatives. The minimum limit for integer values is -2 ^ 31 = -2,147,483,648. I don't know of any easy way to work around this limit, but I'm sure it'd involve something like creating your own number storage system. :/Is there another approach for the difference in time? The integer approach seems to be limited. DOS does not use floating point? Can we instruct the computer to do the arithmetic like we do on paper? When we borrow from hours we borrow 60 minutes? The internet might have an example?The integer in seconds might work? (3600 * 24) - (12 * 3600) = 43200
@echo offecho Wscript.echo eval(WScript.Arguments(0))>evaluate.vbsfor /f "delims==" %%A in ('cscript //nologo evaluate.vbs "(timer)"') do set start=%%AREM TASK TO BE TIMED HEREREM Example:ping www.google.comfor /f "delims==" %%A in ('cscript //nologo evaluate.vbs "(timer)"') do set end=%%Afor /f "delims==" %%A in ('cscript //nologo evaluate.vbs "(%end%-%start%)"') do set longnumber=%%Afor /f "delims==" %%A in ('cscript //nologo evaluate.vbs "FormatNumber(%longnumber%,2,-1)"') do set elapsed=%%Aecho times in secondsecho start %start%echo end %end%echo elapsed %elapsed% second(s)
@echo offfor /f "tokens=1-12 delims=,: " %%A in ('uptime.exe') do ( set UpDays=%%F set UpHours=%%H set Upminutes=%%J set UpSeconds=%%L )set /a seconds=86400*%UpDays%set /a seconds=%seconds%+(3600*%UpHours%)set /a seconds=%seconds%+(60*%UpMinutes%)set /a seconds=%seconds%+%UpSeconds%set /a start=%seconds%REM task(s) to be timed hereping www.google.comping www.bbc.co.ukfor /f "tokens=1-12 delims=,: " %%A in ('uptime.exe') do ( set UpDays=%%F set UpHours=%%H set Upminutes=%%J set UpSeconds=%%L )set /a seconds=86400*%UpDays%set /a seconds=%seconds%+(3600*%UpHours%)set /a seconds=%seconds%+(60*%UpMinutes%)set /a seconds=%seconds%+%UpSeconds%set /a finish=%seconds%set /a elapsed=%finish%-%start%echo Elapsed: %elapsed% second(s)
I want to find out how long a process took by accessing either time or some other object at the beginning of the process, then again at the end and compare them to see how long it took.
@echo OFFrem start - end timeREM time format 12:46:26.94echo start time=%TIME%set HH=%TIME:~0,2%echo Hour=%HH%set MM=%TIME:~3,2%echo minutes=%MM%set /a MM=%MM% * 60echo Total Seconds in given minutes=%MM%set /a HH=%HH% * 3600echo Total seconds in given Hours = %HH%set SS=%TIME:~6,2%echo seconds= %SS%Set /a start=%HH% + %MM% + %SS%echo start time in seconds =%start%echo enter time to sleepset /p sleep=sleep %sleep%Rem end time in secondsecho end time=%TIME%set HH=%TIME:~0,2%echo End Hour=%HH%set MM=%TIME:~3,2%echo minutes=%MM%set /a MM=%MM% * 60echo Total Seconds in given minutes=%MM%set /a HH=%HH% * 3600echo Total seconds in given Hours = %HH%set SS=%TIME:~6,2%echo seconds= %SS%Set /a end=%HH% + %MM% + %SS%echo end time in seconds =%end%set /a totaltime=%end% - %start%echo Total Time used in seconds = %totaltime%
Beware of the confusion Octal/Decimal if the variable is 08 or 09
Numeric values are decimal numbers, unlessprefixed by 0x for hexadecimal numbers, and 0 for octal numbers.So 0x12 is the same as 18 is the same as 022. Please note that the octalnotation can be confusing: 08 and 09 are not valid numbers because 8 and9 are not valid octal digits.