New User Question on Dates

Discussion, questions and support.
Post Reply
tevanoff
Posts: 1
Joined: May 29th, ’20, 13:39

Post by tevanoff » May 29th, ’20, 15:40

I'm a new user - thanks for your patience!
I send emails every week with dates & date ranges. I would like to have a few choices in my date library that are out of the norm.

Current - Fridays date - ie. Friday 5/29/20

Last Week date range = Sunday to Saturday ie. 2020-05-17 thru 2020-05-23

Current Weeks date range = Sunday to Saturday ie. 2020-05-24-20 thru 2020-05-30

Any help on this would be greatly appreciated.
Tom
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » May 30th, ’20, 20:35

You would need to know a bit of scripting (Type: Command) to do this. There are many built-in variables and date calculation/formatting methods available.
https://www.autohotkey.com/docs/Variables.htm#WDay
https://www.autohotkey.com/docs/commands/EnvAdd.htm
https://www.autohotkey.com/docs/command ... _sensitive

For example A_WDay variable is a current 1-digit day of the week (1-7). 1 is Sunday, 2 is Monday etc. The following scripts check the current day of the week and calculate the difference to another date. I think you get the idea and can develop your dates.

Code: Select all

;Next Monday
date := A_Now   ;gets current date
date += 9-A_WDay, Days   ;adds (9 - current day of the week) to current date = next Monday
FormatTime, date, %date%, dd/MM/yyyy   ; formats the date
msgbox %  "Next Monday: " date "`n"
Send, % "Next Monday: " date "`n"

;Next Friday
date := A_Now
date += 13-A_WDay, Days
FormatTime, date, %date%, dd/MM/yyyy
Send, % "Next Friday: " date "`n"

;Last Monday
date := A_Now
date += A_WDay-12, Days
FormatTime, date, %date%, dd/MM/yyyy
Send, % "Last Monday: " date "`n"

;Last Friday
date := A_Now
date += A_WDay-8, Days
FormatTime, date, %date%, dd/MM/yyyy
Send, % "Last Friday: " date
Matthias
Posts: 1
Joined: Jul 4th, ’20, 19:57

Post by Matthias » Jul 4th, ’20, 20:13

I need something similar - I have to refer to week numbers daily, Fastkeys has an option but displays it directly after the 4digit year, i.e. 202027. Could you add a predefined variable for just the week number ? You already have one for the day of the year (which is also useful) so this should be no big thing ?
Thank you
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jul 5th, ’20, 08:30

Thanks, we will implement this in one of the next releases. ;)

Until then you could extract the week number like this (Type: Command):

Code: Select all

Week := SubStr(A_YWeek, -1)
Post Reply