Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Date Appeal - Converting to AM or PM simply

ChrisHub
5 - Atom

Hi all,

 

As we exit out of the DateTime parsing tool, we get: 07-14-2022 19:36:04. And it is stored in a field called [DateTime_Out].

 

I would like it to display: 07-14-2022 07:36 PM.

 

What I'm trying to do to get that desired format is this in a formula tool: 

DateTimeParse([DateTime_Out],'%m-%d-%y %I:%M:%S %p')

 

I get this error:

Formula (8) DATETIMEPARSE: Cannot convert "07-14-2022 19:33:36" to a date/time with format "%m-%d-%y %I:%M:%S %p" and language "English": Hour is out of range 1..12: '19:33:36'

 

How can I express this date/time as mm-dd-yyyy HH:MM  on a 12 hour clock showing AM or PM?

 

thank you,

Chris

4 REPLIES 4
DavidSkaife
13 - Pulsar

Hi @ChrisHub 

 

What are you setting the field data type as? If you create a new field and set it to a string, then use this formula it will work: DateTimeFormat([DateTime_Out],'%m-%d-%Y %I:%M %p')

 

DavidSkaife_1-1657917696156.png

 

 

binuacs
21 - Polaris

@ChrisHub one way of doing this

DateTimeFormat(DateTimeParse([Date_Time],'%m-%d-%Y %H:%M:%S'),'%m-%d-%Y %I:%M:%S %p')

 

binuacs_0-1657919832336.png

 

ChrisHub
5 - Atom

The attached is what I did, but I'm sure after looking at your code I took a long, scenic route to get to the same output. But, I tried using DateTimeFormat, but got that error. So I just experimented with the DateTime Tool's output options and got 'that' to work. I'm going from a UTC format to EST format with AM/PM designation and a 12 hour clock. I believe it works pretty good, but it's slightly Rube Goldberg-ish. 

DavidSkaife
13 - Pulsar

@ChrisHub

 

That is a very scenic route hehe, it works though that's the main thing!

I suspect you were trying the DateTimeFormat on a DateTime field? FYI It must be outputted to a string field otherwise it won't work, as you discovered 😀

Labels
Top Solution Authors