kawliga751

Convert variable (tomorrow) date to MM/DD/YYYY format

5 posts in this topic

#1 ·  Posted

I have established how to get tomorrows date however I can't seem to figure out how to format the date into my required format of MM/DD/YYYY.  

I have this:

$today=_DateToDayValue(@YEAR,@MON,@MDAY)
Dim $Y, $M, $D
$tomorrow=_DayValueToDate($today+1, $Y, $M, $D)

The _DateToDayValue seems to have a fixed format.  I've also tried a :

$vardate = _DateAdd( 'd',1, _NowCalcDate())

with a "StringSplit" and/or StringFormat but the _NowCalcDate seems to also be fixed to a YYYY/MM/DD format.

I'm sure I'm missing something simple but am at a loss.

Any help would be MUCH appreciated

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Have you tried _NowDate?


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#3 ·  Posted

Hello. Try this.

 

#include <Date.au3>
Local $today=_DateToDayValue(@YEAR,@MON,@MDAY),$Y, $M, $D
Local $tomorrow=_DayValueToDate($today+1, $Y, $M, $D)
$tomorrow= StringFormat("%02i/%02i/%04i", $M,  $D,  $Y)
ConsoleWrite($tomorrow & @CRLF)

Saludos

1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted

Danyfirex:

This worked PERFECTLY!. I have never seen s StrngFormat like this and, I would've probably NEVER found it on my own. MANY Thanks

Share this post


Link to post
Share on other sites

#5 ·  Posted

You're welcome mate.

 

Saludos

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

  • Similar Content

    • ur
      By ur
      To get the current time stamp, I got the below code.
      #include <Date.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #RequireAdmin ; Under Vista the Windows API "SetSystemTime" may be rejected due to system security $td = _Date_Time_GetSystemTime() $td = _Date_Time_SystemTimeToDateTimeStr($td) $td = StringReplace($td, " ", "_") $td = StringReplace($td, ":", "_") MsgBox(0,"",$td) But it is not giving the date or time of the timezone where the system is there.
      Please suggestt
    • SkysLastChance
      By SkysLastChance
      I am not sure what is happing at all, unfortunatlly there is no way I can put a full running code. When I enter the first and last name it works fine, However when I get to the date of birth it puts in '19760703000000' 
       
      I can't figure out why "7/3/1976" is the value before the formant and "07031976" is after the format. 
       
      I want it to pull the value after the format. "07031976"
       
       
      $r = 1 Local $aArray = _Excel_RangeRead($oExcel, Default, Default,Default,False) For $i = 1 To UBound($aArray) - 1 ;$i =0 Start from row A $sR1 = $aArray[$i][0] ;status $sR2 = $aArray[$i][1] ;first name $sR3 = $aArray[$i][2] ;Last name $sR4 = $aArray[$i][4] ;DOB $sR5 = $aArray[$i][5] ;Email Address WinWaitActive ("[CLASS:Notepad]") ControlSend("[CLASS:Notepad]", "", "Edit1", $sR3 & ',' & $sR2 & @CR) Sleep (2000) ControlSend("[CLASS:Notepad]", "", "Edit1",("{TAB}")) Sleep (3000) ControlSend("[CLASS:Notepad]", "", "Edit1", $sR4 & @CR) ControlSend("[CLASS:Notepad]", "", "Edit1",("{ENTER}")) ControlSend("[CLASS:Notepad]", "", "Edit1",("{F12}") $r = $r + 1 If $r > $sBox Then Exit Endif Next auto it demo.xlsx - excel that I am using.
      Edit: I also want to mention I have tried
      Local $aArray = _Excel_RangeRead($oExcel, Default, Default,3) When I do this not even the name first and last name will write.
    • ur
      By ur
      When I tried the below code, I am getting the date in mm-dd-yyyy format.
      But I require dd-mm-yyyy format.
      Can anyone suggest how to do that.
      Func TodaysDate() return StringReplace(_DateTimeFormat(_NowCalc(), 2), "/", "-") EndFunc Earlier I tried dd-mmm-yyyy format and it is working with below code.
      Func TodaysDate() $NewDate = _DateTimeFormat(_NowCalcDate(),1) $Array = StringSplit( $NewDate , ',' ) _ArrayDelete($Array, 0) _ArrayDelete($Array, 0) $Array1 = StringSplit($Array[0],' ') RemoveEmptyArrayLines($Array1) $Date = StringStripWS($Array1[2]&"-"&StringLeft($Array1[1], 3)&"-"&$Array[1], $STR_STRIPALL) return $Date EndFunc Which is unnecessarily complicated I feel., the approach
      Now I need format of dd-mm-yyyy.
      Can anyone suggest how to do this.
    • MrCheese
      By MrCheese
      Hi guys,
       
      I have some code; which doesn't quite work.
      $dateStop = "11302015" $tDate = _Date_Time_GetSystemTime() $currentdatestring = _Date_Time_SystemTimeToDateStr($tDate) If $currentdatestring >= $dateStop Then MsgBox(0, "Expired", "Script has expired.") Exit EndIf  
      Basically, I want to essentially put an expiry date on the script.
       
      Where in the example above, it is 30th November 2015.
       
      Sometimes it works, sometimes it doesn't. 
      I may have the string wrong, I may have the code all wrong.
       
      I thought about using the macro @mon @year etc but it gets quite conditional.
      i.e. if its 2015, but October, or if its 2015 and Dec, or if its March 2016 etc.
       
      But simplicity is great. Any help would be awesome.