4 posts in this topic
I have date in the string format as "DD-MM-YYYY".
I need to get yesterday's date from it.
I tried converting this from _DateTimeFormat but not working.
Is there any direct UDF available to get this.?
In some systems the date is displayed in the Taskbar as
And in some systems it is like, 1/10/2018
And in some it is, 10-Jan-2018
And in different formats.
I wrote my code to convert 1/10/2018 to 10-01-2018
Func TodaysDate() $NewDate = _DateTimeFormat(_NowCalcDate(),1) $Array = StringSplit( $NewDate , ',' ) _ArrayDelete($Array, 0) _ArrayDelete($Array, 0) $Array1 = StringSplit($Array,' ') RemoveEmptyArrayLines($Array1) ;Will return the present day's date with format dd-mmm-yyyy ;$Date = StringStripWS($Array1&"-"&StringLeft($Array1, 3)&"-"&$Array, $STR_STRIPALL) $Date = StringStripWS($Array1&"-"&changeDateformat(StringLeft($Array1, 3))&"-"&$Array, $STR_STRIPALL) return $Date EndFunc Func RemoveEmptyArrayLines(ByRef $arrLines) $intCount = 1 While $intCount < UBound($arrLines) $arrLines[$intCount] = StringStripWS($arrLines[$intCount],$STR_STRIPLEADING + $STR_STRIPTRAILING) If StringLen($arrLines[$intCount])=0 Then _ArrayDelete($arrLines, $intCount) $intCount = $intCount - 1 EndIf $intCount = $intCount + 1 WEnd EndFunc ;To convert mmm to mm format Func changeDateformat($sText) Local $sMsg = StringStripWS($sText, $STR_STRIPALL) Switch $sMsg Case "Jan" $sMsg = "01" Case "Feb" $sMsg = "02" Case "Mar" $sMsg = "03" Case "Apr" $sMsg = "04" Case "May" $sMsg = "05" Case "Jun" $sMsg = "06" Case "Jul" $sMsg = "07" Case "Aug" $sMsg = "08" Case "Sep" $sMsg = "09" Case "Oct" $sMsg = "10" Case "Nov" $sMsg = "11" Case "Dec" $sMsg = "12" EndSwitch return $sMsg EndFunc But again it will work on machines only with 1/10/2018.
Is there any direct function which will give only in the format 10-01-2018, whatever the system settings is.?
I tried all the arguments for _DateTimeFormat, but showing machine dependent settings only.
Google given these two links in AutoIT but these are also for specific formats only,like mine.
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
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.
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.