uj24153
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022
04:23 AM
How to convert a string to date.
Hi guys, I am trying to convert a string to Date but cannot find a solution. so that is why i need your help.
I am getting date from api response as follows,
03/08/2022
but i am unable to change it to Date, i want to sort an array on basis of Date so that is why i am doing this if anyone can help me to sort an assoc Array without changing it to date that will be more helpful,
Thanks in advance.
Thanks in advance.
1 REPLY 1
thomasferraro
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2022
01:29 PM
Re: How to convert a string to date.
' You can't sort an associative array. Values are accessed via their keys
' To convert a string to a Date object:
date = CreateObject("roDateTime") ' creates date object with current date
print(date.AsDateString("long-date")) ' prints Saturday August 6, 2022
dateString = "2022-03-08 00:00:00.000" ' string must be in ISO8601 format
date.FromISO8601String(dateString)
print(date.AsDateString("long-date")) ' prints Tuesday March 8, 2022