How do I add weeks to a given date, say date_given?
I would like to implement the equivalent of following VBA function:
DateAdd("ww", 4, date_given)
This function adds 4 weeks to date_given.
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/dateadd-function
How to add weeks to a date
Re: How to add weeks to a date
Hallo,
Autohotkey unfortunately does not make it so comfortable.
https://www.autohotkey.com/docs/commands/EnvAdd.htm
Autohotkey unfortunately does not make it so comfortable.
https://www.autohotkey.com/docs/commands/EnvAdd.htm
Re: How to add weeks to a date
maybe add 28 days
Code: Select all
weeks :=4
daysx :=(weeks*7)
dategiven:=a_now
diff += daysx,days
formattime,xx,%diff%,yyyy-MM-dd
msgbox,%xx%
return
Re: How to add weeks to a date
Well, it shouldn't be too tough to create a full-blown AHK-UserDefinedFunction that can deal with almost if not all interval-formats of that DateAdd()-function.
The main issue I saw was the input-format of the date_given-parameter, but it looks that this can be solved as well ...
https://autohotkey.com/board/topic/18760-date-parser-convert-any-date-format-to-yyyymmddhh24miss/
Good luck
The main issue I saw was the input-format of the date_given-parameter, but it looks that this can be solved as well ...
https://autohotkey.com/board/topic/18760-date-parser-convert-any-date-format-to-yyyymmddhh24miss/
Good luck
Re: How to add weeks to a date
@BoBo , thanx, DateParse, great script from user polyethene
Code: Select all
;- Converts almost any date format to a YYYYMMDDHH24MISS value.
;- user polyethene
;- https://autohotkey.com/board/topic/18760-date-parser-convert-any-date-format-to-yyyymmddhh24miss/
;- https://github.com/Paris/AutoHotkey-Scripts/blob/master/DateParse.ahk
;------------------------------------------------
time := DateParse("2:35 PM, 27 November, 2007")
msgbox,%time%
return
Re: How to add weeks to a date
Check out @jeesweeg's https://www.autohotkey.com/boards/viewtopic.php?t=65544#add_date . He also mentioned that DateAdd() is a function available in AHK 2.0 !! It might make sense if someone starts coding with AHK to do it with AHK 2.0 (or AHK_H) for exactly that reason. Make up your mind. Good luck
Who is online
Users browsing this forum: Google [Bot] and 187 guests