question

Nicolas Mbz avatar image
0 Likes"
Nicolas Mbz asked Nicolas Mbz commented

How to convert date from string to DateTime ?

I want to convert this date format (string) to DateTime in order to get the dayoftheweek() and hour(). I saw that there is a convert function, but I don't understand how to use it. Can you help me?


string dateTime_str = "15.03.2019 09:37";

DateTime DT = convert(dateTime_str, DATETIME_STR,FS_DATETIME);

return DT;

FlexSim 22.1.0
datetimeconvert
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Nicolas Mbz commented

Try this:

string dateTime_str = "15.03.2019 09:37";
DateTime dt=DateTime(dateTime_str,"%d.%m.%Y %H:%M");
return [dt.dayOfWeek,dt.hour];

The datetime constructor is documented here.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Nicolas Mbz avatar image Nicolas Mbz commented ·

It works ! Thanks !

where can i find this type of explanation in the help (DateTime(dateTime_str,"%d.%m.%Y %H:%M") ?

0 Likes 0 ·
Nicolas Mbz avatar image Nicolas Mbz Nicolas Mbz commented ·
found, thanks a lot !
0 Likes 0 ·