Forum Discussion

uj24153's avatar
uj24153
Binge Watcher
3 years ago

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.
  • ' 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