Alteryx Designer Desktop Discussions

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

Date conversion question

Manjari
8 - Asteroid

 

I tried 2 different methods to parse a date i have "26/07/2018", which is a string 

1. Used the datetime tool, the output is "2026-07-20 18:00:00"

2. Used the formula "DateTimeParse([Date],"%Y-%m-%d %H:%M:%S")", the output is "2026-07-20 18:00:00"

 

I need the output: 26-07-2018 18:00:00 in datetime data type

Not sure where i am going wrong, requesting your help

2 REPLIES 2
JohnJPS
15 - Aurora
Try DateTimeParse using the format of your current string (e.g. slashes, not dashes). That will give you your DateTime format. Please note that the DateTime data type is not display specific. If you want it to display in a different format (e.g. dashes, not slashes), then use DateTimeFormat, which will give you a string in your desired display format.
JoshKushner
12 - Quasar

Unfortunately you can't have that format as a 'datetime' type as that is only available for a specific date format in Alteryx: yyyy-MM-dd.

 

You can get the format you want as a 'string' by:

First converting your date to a 'datetime' type,

Second converting the format stored as a 'string' type. Make sure you string size is large enough to fit everything (at least 20).

 

Step 1

Convert the date string to 'datetime' type

 

Formula Tool

DateTimeParse([Date],'%d/%m/%Y')

DateTime Parse Tool

dd/MM/yyyy

Step 2

Add 18 hours to your datetime

 

Format Tool

DateTimeAdd([Date (Converted)],18,'hours')

 

Step 3

Convert your datetime back to a 'string' type in the format you want

 

Formula Tool

DateTimeFormat([Date (Converted)],'%d-%m-%Y %H:%M:%S')

Formula Tool

Formula.PNG

Labels