Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Convert text to datetime

MichaelJack
6 - Meteoroid

Hi guys,

I need to convert a text field to datetime or timestamp in alteryx but i failed to use the datetime tool because the value looks difference that normal.
Please help to advice me on this:

2018-01-01T07:57:29.000Z
2017-12-31T23:48:40.000Z
2018-01-03T18:40:31.000Z
2018-01-02T20:59:09.000Z

 

I need get the date and the hour per each row before inserting to my SQL Server.

Thank in advanced.

M.

3 REPLIES 3
MarqueeCrew
20 - Arcturus
20 - Arcturus
Your data is almost there. I would replace the T with a space. Next I would replace .000Z with "". Then it is ready to be changed to a datetime data type in a select tool.

Cheers,
Mark
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
BenMoss
ACE Emeritus
ACE Emeritus

So you want to choose custom mode in this instnace with the following statement...

 

%Y-%m-%dT%H:%M:%S.000Z

I.e. the first four characters represent the year

then theres a dash

then the month

then the day

then a T

then the hour

then a colon

then the minutes

then a colan

then the seconds

then a fullstop and 000Z

 

milliseconds are not supported. This will only work if the suffix is always .000Z

 

Alternatively you could trim these characters from the string before using the date time tool (if they vary say .001 and .050), before using a statement like...

 

%Y-%m-%dT%H:%M:%S
MichaelJack
6 - Meteoroid

Thank for your advice!

It works perfect

 

Regards,
M.

Labels