Sign in to follow this  
Followers 0
gcue

preserve Zeros

5 posts in this topic

hello.

i am trying to get yesterdays date with this:

MsgBox(0,"",_DateTimeFormat(_DateAdd("D",-1,_NowCalcDate()),0))

but i am trying to preserve the zeros when either the month or day are single digit...

ie: 01/04/2009 instead of 1/4/2009

any ideas?

thanks!

Share this post


Link to post
Share on other sites



Maybe replace _NowCalcDate with

@YEAR & "/" & @MON & "/" & @MDAY

See Macros


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Notice that most return values are two-digits long.

From the 'Time and Date Macros' section of the AutoIt help file

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

but i am trying to preserve the zeros when either the month or day are single digit...

ie: 01/04/2009 instead of 1/4/2009

Change your pc's regional short date to "dd/MM/yyyy" or use

ConsoleWrite(StringRegExpReplace(_DateAdd("D",-1,_NowCalcDate()), '(\d+)/(\d+)/(\d+)', '$3/$2/$1') & @LF)
instead of _DateTimeFormat

Share this post


Link to post
Share on other sites

perfect! thanks!!

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