Sign in to follow this  
Followers 0
Rex

_DateDiff() in Days, Hours, Min and sec

4 posts in this topic

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 :unsure:

Cheers

/Rex

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

come on ... this should be easy for you :unsure:

$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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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 :unsure: , 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 :D

Cheers

/Rex

Share this post


Link to post
Share on other sites

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. :unsure:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0