The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
Convert Time Format
Hi All,
I need some help with converting my time format. Within the dataset that I have, my time is in 24 hour format eg. 19:00 and 00:00. I am trying to convert these times into 12 hour format where 19:00 would turn into 7:00pm and 00:00 would turn into 12:00am.
I used Nominal to Date operator, and set the date type to time, date format to h:mm a, but it's giving me a cannot parse date error since 00:00 is an unparseable date. Any thoughts on solving this problem?
Thanks!
1
Answers
hello @jason_xie - I really should defer to @Marco_Boeck on this as I know how much he likes working with dates and times. But does this help?
Scott
Thanks so much, seems like it works the best if the variable has both date and time information. In my case, I have date and time as 2 different variables and the best way to approach it is to concac these two variables together and convert the time format then.
Would love to hear if @Marco_Boeck[community.rapidminer.com] has any other inputs on this issue.
Hi @jason_xie,
the format you were probably searching for was simply "hh:mm" and not "hh:mm a".
The date format parameter within the Operator Nominal to Date needs to know what the Attribute looks like.This means if your Attribute does not have AM or PM, the conversion cannot work.
If your string only has values like 00:00 then this setting will not work.
By the way:
Whereas the attribute types date / time / date_time are internally stored in milliseconds since 01/01/1970, the *visual* representation in RapidMiner is always of the format "MMM dd, yyyy hh:mm:ss a z" (e.g. Nov 20, 2017 1:16:53 PM CET).
If you want to have a different visualization you can only convert the attribute to nominal using the Operator Date to Nominal or a conversion function within Generate Attributes (e.g. date_str_custom()).
Best regards,
Edin
Dortmund, Germany