timetypestype-conversionalteryx

Alteryx Convert String to Time


I have a column of times in ALteryx like the following:

Time
=====
8:05 AM
8:07 AM
8:11 AM
8:12 AM
8:16 AM
...

They are currently stored as a String, but I want to convert them to the Time format. So far, I have tried using the LEFT and TRIM function to isolate the time itself as such:

Trim(Left([Time], 5)," ")

However, when I try to convert this to a Time datatype, I receive type conversion errors. How can I convert something like 8:46 AM from a String to a Time datatype in Alteryx?


Solution

  • I did some more digging and trying different things out, and I was able to figure it out. For the reference of others, here is what I did:

    DateTimeParse([VisitTime] + " " + [PartofDay],"%I:%M %P")
    

    Where [VisitTime] is the time expressed like 8:30 and [PartofDay] is AM or PM.

    After this, I used a Select tile to change the datatype from String to Time without type conversion errors.