Jump to content
Sign in to follow this  
Diana (Cda)

Changing custom day format.

Recommended Posts

Diana (Cda)

Some time back I was kindly given this specialized date format that I use constantly, i.e., in backup names to show date. It decreases the standard 3-character short date format to just 2 characters:

$ShortDayMyFormat = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(@WDAY,1) ), 2)oÝ÷ ØÊøvÚ,¹»kiËhçZÉ«­¢+ØÀÌØíM¡½ÉÑå5å½ÉµÐôMÑÉ¥¹5¥ ÅÕ½ÐíM¸±5¸±QÔ±]±Q ±È±MÅÕ½Ðì°MÑÉ¥¹%¹MÑÈ ÅÕ½ÐíMÕ¹5½¹QÕ]Q¡ÕÉ¥MÐÅÕ½Ðì°}Ñå=]¬¡]d´Ä°Ä¤¤°È
For some reason, though "-1" above with @WDAY (and @MDAY elsewhere in script) gives me yesterday's date in both day of month and day of week, anything beyond that becomes unreliable ... i.e., when I try using "-2", "-3" and beyond. So even though 0 for today and -1 for yesterday works, this technique must actually not be the correct way since anything beyond that gives some pretty wacky results sometimes.

Is there a way to get dates based on a starting date and subtracting from it??

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites
water

With _DateAdd you can subtract as well. See example 2 in the helpfile.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Malkey

Some time back I was kindly given this specialized date format that I use constantly, i.e., in backup names to show date. It decreases the standard 3-character short date format to just 2 characters:

$ShortDayMyFormat = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(@WDAY,1) ), 2)

Modified to subtract one day:

$ShortDayMyFormat = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(@WDAY-1,1) ), 2)

For some reason, though "-1" above with @WDAY (and @MDAY elsewhere in script) gives me yesterday's date in both day of month and day of week, anything beyond that becomes unreliable ... i.e., when I try using "-2", "-3" and beyond. So even though 0 for today and -1 for yesterday works, this technique must actually not be the correct way since anything beyond that gives some pretty wacky results sometimes.

Is there a way to get dates based on a starting date and subtracting from it??

Using Mod() in _DateDayOfWeek() will produce a zero which is not allowed as a parameter. "One" must be added after the Mod() to avoid zero. To keep today's day of the week correct, "minus one" is added within the Mod() function.

;
#include <Date.au3>

Local $sRes = ""

For $x = -11 To 9

    $ShortDayMyFormat = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", _
            StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(Mod(49 + @WDAY + $x, 7) + 1, 1)), 2)

    $sRes &= $x + 1 & " days  from today = " & $ShortDayMyFormat & @CRLF
Next

$sRes &= @CRLF & "Today is = " & StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", _
        StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(Mod(49 + @WDAY - 1, 7) + 1, 1)), 2)

MsgBox(0, "", $sRes)
;

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.