Sign in to follow this  
Followers 0
John117

Time format help needed. -simple for someone . . .

10 posts in this topic

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

Share this post


Link to post
Share on other sites



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!

Share this post


Link to post
Share on other sites

maybe:

ConsoleWrite("1" & StringTrimRight(_DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(_NowCalc(), 3),3) & ":00" & @CRLF)


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

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 . . .?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Does a single digit "Wild card" exist for stringreplace?

such as

:* = : and everything after :

:??? = : and three characters after :

Edited by Hatcheda

Share this post


Link to post
Share on other sites

Better?

ConsoleWrite("1" & _DateTimeFormat(_NowCalc(), 2) & " " & _DateTimeFormat(StringTrimRight(_NowCalc(), 2) & "00",3) & @CRLF)

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

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

Share this post


Link to post
Share on other sites

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!

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