4 posts in this topic
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.
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,' ') RemoveEmptyArrayLines($Array1) $Date = StringStripWS($Array1&"-"&StringLeft($Array1, 3)&"-"&$Array, $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.
I decided to enhance the functionality of the OOo COM UDF found >here and >here. Thanks to Leagnus and Andy G for providing the initial functions and framework.
This UDF includes the following working functions:
Please help me test this and let me know of any problems, questions, suggestions or comments you may have.
Edit (August 5, 2016): Latest files have been uploaded. Script-breaking changes include renaming the functions to start with _OOoCalc_.
Edit (November 14, 2016): New version, including fixed sort function!
Edit (November 15, 2016): Lots of minor changes including tightening up the error checking.
Edit (November 16, 2016): Added ByRef to object parameters. Edited demo.
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.