John117 Posted March 13, 2009 Share Posted March 13, 2009 Hey guys, Can anyone help me with this . . . I haven't worked with time much and can't find much in the help example other than time difference. I have included an example below. Thanks! #include <Date.au3> ;1 (Minutes) needs this format and rounded down to 00 for seconds ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF) ;needs this format, 15 minutes earlier, and rounded down to 00 for seconds ConsoleWrite("2" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF) ;2 (Hours) needs this format and rounded down to 00 for minutes, 00 for seconds ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF) ;needs this format, 15 hours earlier, and rounded down to 00 for minutes, 00 for seconds ConsoleWrite("2" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF) Run it in SciTE and look at the bottom to see the results as they are . . . currently Link to comment Share on other sites More sharing options...
John117 Posted March 13, 2009 Author Share Posted March 13, 2009 Ok, After finding a post from PSaltyDS #include <Date.au3> ;$sRET = (_DateAdd("s", -1 * ((2 * 86400) + (3 * 3600) + (4 * 60) + 5), _NowCalc())) ;1 (Minutes) needs this format and rounded down to 00 for seconds ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF) ;needs this format, 15 minutes earlier, and rounded down to 00 for seconds ConsoleWrite("2" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( (_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())),3) & @CRLF) ;2 (Hours) needs this format and rounded down to 00 for minutes, 00 for seconds ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF) ;needs this format, 15 hours earlier, and rounded down to 00 for minutes, 00 for seconds ConsoleWrite("2" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF) Any help rounding the Seconds down to 00? Thanks! Link to comment Share on other sites More sharing options...
Developers Jos Posted March 13, 2009 Developers Share Posted March 13, 2009 maybe: ConsoleWrite("1" & StringTrimRight(_DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(_NowCalc(), 3),3) & ":00" & @CRLF) 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. Link to comment Share on other sites More sharing options...
John117 Posted March 13, 2009 Author Share Posted March 13, 2009 maybe: ConsoleWrite("1" & StringTrimRight(_DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(_NowCalc(), 3),3) & ":00" & @CRLF) #include <Date.au3> $sRET = (_DateAdd("s", -1 * ((2 * 86400) + (3 * 3600) + (4 * 60) + 5), _NowCalc()));MsgBox(64, "Result", "2 days, 3 hours, 4 minutes, and 5 seconds ago was: " & $sRET) ;1 (Minutes) needs this format and rounded down to 00 for seconds ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF) ;needs this format, 15 minutes earlier, and rounded down to 00 for seconds ConsoleWrite("2" & _DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())),2) _ & " " & _DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())),3) & @CRLF) ;2 (Hours) needs this format and rounded down to 00 for minutes, 00 for seconds ConsoleWrite("1" & _DateTimeFormat( _NowCalc(),2) & " " & _DateTimeFormat( _NowCalc(),3) & @CRLF) ;needs this format, 15 hours earlier, and rounded down to 00 for minutes, 00 for seconds ConsoleWrite("2" & _DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (15 * 3600) + (0 * 60) + 0), _NowCalc())),2) _ & " " & _DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (15 * 3600) + (0 * 60) + 0), _NowCalc())),3) & @CRLF) ConsoleWrite("1" & StringTrimRight(_DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(_NowCalc(), 3),3) & ":00" & @CRLF) Causes: 13/13/2009 3:20:47 PM 23/13/2009 3:05:47 PM 13/13/2009 3:20:47 PM 23/13/2009 12:20:47 AM 13/13/2009 3:20:47:00 Based on that, I was thinking maybe a string search and replace :?? once for the first one and twice for the second one . . .? Link to comment Share on other sites More sharing options...
John117 Posted March 13, 2009 Author Share Posted March 13, 2009 (edited) Does a single digit "Wild card" exist for stringreplace? such as = : and everything after : :??? = : and three characters after : Edited March 13, 2009 by Hatcheda Link to comment Share on other sites More sharing options...
Developers Jos Posted March 13, 2009 Developers Share Posted March 13, 2009 my pc's time format is 24 hour not 12 thats why we see the difference. 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 13, 2009 Developers Share Posted March 13, 2009 Better? ConsoleWrite("1" & _DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(StringTrimRight(_NowCalc(), 2) & "00",3) & @CRLF) 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. Link to comment Share on other sites More sharing options...
John117 Posted March 13, 2009 Author Share Posted March 13, 2009 Yes, That worked for seconds. Now I will try to adapt it to run for minutes and seconds. let ya know in a few min . . Link to comment Share on other sites More sharing options...
Developers Jos Posted March 13, 2009 Developers Share Posted March 13, 2009 I am sure you can do that 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. Link to comment Share on other sites More sharing options...
John117 Posted March 13, 2009 Author Share Posted March 13, 2009 Jos, Thank you so much! Ya made that look harder than it was when I finally figured what you had done. It kept rejecting until I got the format right to accept the dateformat outside of the string change. ConsoleWrite("1" & (_DateTimeFormat((_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())), 2) & " " & (_DateTimeFormat(StringTrimRight((_DateAdd("s", -1 * ((0 * 86400) + (0 * 3600) + (15 * 60) + 0), _NowCalc())), 5) & "00:00",3))) & @CRLF) Works like a charm! Link to comment Share on other sites More sharing options...
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