community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Convert text to datetime

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.

Alteryx Certified Partner
Alteryx Certified Partner
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 reboot. Order shall return.
Alteryx Certified Partner
Alteryx Certified Partner

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
Highlighted
Meteoroid

Thank for your advice!

It works perfect

 

Regards,
M.

Labels