„Format/Date Time“ Activity with Dates before 1970
I recently answered a forum post where a participant told about „Weird date format issue when selected date is before 1970s“.
With input dates after 01/01/1970 the output is correct, but with dates after you get:
The input time is not valid, or the format is incorrect. Input Time: 10/21/1968 Input Format: MM/dd/yyyy
Indeed the” Format Date/Time “Activity has weird results when the Input Date is before 1970.
So, you get a problem for example if you have a self-service Request Offering in Service Manager and want to format birthdate of an employee who is born before 1970.
With this PowerShell Script and a “Run .Net Script” Activity you can work around this issue:
[datetime]$InputUTCDate='10/20/1968 22:00:00.000' $InputLocalDate=[System.TimeZone]::CurrentTimeZone.ToLocalTime($InputUTCDate) $Output=$InputLocalDate.ToString("dd.MM.yyyy")