Diana (Cda)

Change output date format in next Monday's date?

2 posts in this topic

#1 ·  Posted (edited)

Hello!

I found an excellent bit of coding googling, which gives me next Monday's date which I then changed around a bit.

It is this:

#include<date.au3>
#NoTrayIcon     ; AutoIt's icon doesn't show in systray
TraySetIcon("Shell32.dll", 24)     ; changes the icon displayed in the systray
AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!
;-------------------------------------------------------------------------------------------------------------------------



;==========================================================
$WorkEmailAddress = ""
;==========================================================

$iWeekday = _DateToDayOfWeekISO (@YEAR, @MON, @MDAY)
$MondayCalculation = _DateAdd("d",7-$iWeekday,_NowCalcDate())
$NextMonday = StringReplace($MondayCalculation, "/", ".")

ShellExecute('mailto:' & $WorkEmailAddress & '&subject=PS'' Key Deliverables - Weekly Priorities ' & $NextMonday &  '%20%28Aug%2003%29%2E&body=Good%20Morning%21%0A%0APlease%20update%20the%20information%20below%20and%20return%20to%20me%2E%0A%0AMerci%21%0A%0A')

The output for the subject line in the above needs more finetuning that I can do.  This is the text string that appears in the subject line when invoked now:

PS' Key Deliverables - Weekly Priorities 2015.10.26 (Aug 03)

I typed in Aug and 03 manually, so that part is no good, of course.

What is needed is this slight variation of the above.  Adding .Mn (or .Tu, .Wd, .Th) to the end of the date, and the actual date in brackets, like this:  (mmm dd):

PS' Key Deliverables - Weekly Priorities 2015.10.26.Mn (Oct 26).

Now I don't know how to incorporate it here, but just in case it is of any help, I have this syntax that gives me my custom short day of the week format:

Local $ShortDayMyFormat = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", $sWkDay), 2)

Thank you!  Any help appreciated in getting the .mm and (mmm dd) information missing, to get the above type of subject line:

PS' Key Deliverables - Weekly Priorities 2015.10.26.Mn (Oct 26).

Cheers!

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites



This _DateConvert function should help.

#include <Date.au3>

#NoTrayIcon     ; AutoIt's icon doesn't show in systray
TraySetIcon("Shell32.dll", 24) ; changes the icon displayed in the systray
AutoItSetOption("WinTitleMatchMode", 2) ; this allows partial window titles to be valid!
;-------------------------------------------------------------------------------------------------------------------------

;==========================================================
$WorkEmailAddress = ""
;==========================================================

$iWeekday = _DateToDayOfWeekISO(@YEAR, @MON, @MDAY)
$MondayCalculation = _DateAdd("d", 8 - $iWeekday, _NowCalcDate())

Local $DatFormat = _DateConvert($MondayCalculation, "yyyy.MM.dd.") & _
        StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", _DateConvert($MondayCalculation, "ddd")), 2) & _
        _DateConvert($MondayCalculation, " (MMM dd)")

MsgBox(0, "Result", 'PS'' Key Deliverables - Weekly Priorities ' & $DatFormat)
;ShellExecute('mailto:' & $WorkEmailAddress & 'PS'' Key Deliverables - Weekly Priorities ' & $DatFormat)


;===== The following converts $Time to $sRetFormat format using Date Control ======
; $Time is in this format "yyyy/MM/dd HH:mm:ss"
; Ref: https://msdn.microsoft.com/en-us/library/bb761726%28v=VS.85%29.aspx#dtp_format_chars
Func _DateConvert($Time, $sRetFormat)
    Local $hGui = GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate($Time, 10, 10, 185, 20)
    GUICtrlSendMsg($idDate, 0x1032, 0, $sRetFormat)
    Local $sRet = GUICtrlRead($idDate)
    GUIDelete($hGui)
    Return $sRet
EndFunc   ;==>_DateConvert

 

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