Rex Posted May 16, 2011 Posted May 16, 2011 Hey Can any of u cool autoit users help me with this math. prob.? I know that as default i can set datediff to putput in either days, hours, mins or secs, put i need to break it down so i get the result in d+h+m+s=total diff eg. diff = TotalSeconds=176461 so it should be something like 2 days 1 hours 1 min and 1 sec. I think thats it's a simple mat thing, but i didn't really see eye 2 eye with my math teacher, so i spend most of my time either at the principals office or just out site the door - so i have no clue how th do the math at this, and there for hoping that some on could help me with the problem. I did try to google but all i got was something about +-3600/86400 and modulus and so, but it didn't help me course i don't know what to do with info I'm not asking any one to writhe a script for me or some thing like that, just to help me on how to the math thing Cheers /Rex
Developers Jos Posted May 16, 2011 Developers Posted May 16, 2011 (edited) come on ... this should be easy for you $isec=176461 $days = Int($isec/(24*60*60)) $remain=Mod($isec,(24*60*60)) $Hours = Int($remain/(60*60)) $remain=Mod($remain,(60*60)) $Mins = Int($remain/60) $Secs=Mod($remain,60) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $days = ' & $days & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Hours = ' & $Hours & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Mins = ' & $Mins & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Secs = ' & $Secs & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Edited May 17, 2011 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Rex Posted May 17, 2011 Author Posted May 17, 2011 come on ... this should be easy for you $isec=176461 $days = Int($isec/(24*60*60)) $remain=Mod($isec,(4*60*60)) $Hours = Int($remain/(60*60)) $remain=Mod($remain,(60*60)) $Mins = Int($remain/60) $Secs=Mod($remain,60) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $days = ' & $days & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Hours = ' & $Hours & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Mins = ' & $Mins & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Secs = ' & $Secs & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Cool Thx for the math Jos But I think... I think i really need to go back to school , course i under stand nothing of thoes calcs think gues i'm an . I gues that the first part 24*60*60 is D*H*M but where does the 4*60*60 comes from ? I should realy haved lissent to what my teatcher was teatching me, instead of barthering him maby u could cut it out in paper for me please , like to know what it actely does, instead of just knowing it does something if you have the time (and patiens) to maby teatch a dummy Cheers /Rex
Developers Jos Posted May 17, 2011 Developers Posted May 17, 2011 I gues that the first part 24*60*60 is D*H*M but where does the 4*60*60 comes from ?That is a typo and of course should be 24.Just do some research to what I did because the time it took to type your post should be enough to understand the approach I took. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now