Page 1 of 1
Is it possible to convert a German date?
Posted: 26 May 2022, 08:24
by mrdigitalis
Dear members,
Is it possible with FormatTime to add an inputdate like: 31.01.2022 (this is how Germans write a date) to this outputdate: YYYYMMDD ?
I have no clue how to do that. Can somebody please help me on my way with it?
Thanks in advance!
Re: Is it possible to convert a German date? Topic is solved
Posted: 26 May 2022, 08:45
by BoBo
Code: Select all
d := StrSplit("31.01.2022",".")
MsgBox % d.3 d.2 d.1
Und hier für Profis:
https://github.com/Paris/AutoHotkey-Scripts/blob/master/DateParse.ahk
Re: Is it possible to convert a German date?
Posted: 26 May 2022, 09:25
by mrdigitalis
@bobo wow that simple! Thank you very much!
Re: Is it possible to convert a German date?
Posted: 26 May 2022, 14:10
by Rohwedder
Hallo,
my method to calculate dates with known TimeStamps:
Code: Select all
GTimeStamp = dd.MM.yyyy ;Germans write a date
MsgBox,% Date := TimeStamp("31.01.2022",GTimeStamp)
; 20220131120000 (Noon if time not given)
Date += 1234, days ;EnvAdd
FormatTime, Date,% Date, %GTimeStamp%
MsgBox,% Date ;18.06.2025 = 31.01.2022 + 1234 days
TimeStamp(Date, Format:="")
{
Static Noon := A_Year A_MM A_DD 120000, Down := 7060504030201, FOld
FormatTime, D,% 8 Down,% Format?FOld:=Trim(Format):FOld
For all, V in ["Date","D"], Date := Trim(Date) ; add missing leading zeros
%V% := RegExReplace(%V%, "(?<=^|\D)(\d)(?=\D|$)", "0$1")
Loop, Parse,% (0 Down, N := Noon) ; today's noon
IF A_LoopField And Pos := InStr(D, A_LoopField)
N := SubStr(N,1,A_Index-2) SubStr(Date,Pos-1,2) SubStr(N,A_Index+1)
Return, N ; digits >0 from Down in D stand for Date's values
}
Re: Is it possible to convert a German date?
Posted: 29 May 2022, 03:55
by mrdigitalis
Danke auch! @Rohwedder