Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

How to separate date and time

rmartinez4
8 - Asteroid

Hi it possible to show how to separate the date and time.

 

Last Seen Date
2022-08-17 13:15:46GMT
2022-08-17 14:50:01GMT
2022-08-17 06:30:06GMT

 

Last Seen Date - Zscaler      Time
2022-08-17                          13:15:46GMT
2022-08-17                          14:50:01GMT
2022-08-17                          06:30:06GMT

11 REPLIES 11
michelle_mathews
Alteryx Alumni (Retired)

Hi @rmartinez4 , I'd recommend the Text To Columns tool to split on the space between date and time

Maskell_Rascal
13 - Pulsar

Hi @rmartinez4 

 

If you're not looking to convert the date or time into any specific format, you can use a Text to Columns tool configured like so. 

Maskell_Rascal_0-1660845236696.png

 

Let me know if that works for you. 

 

Cheers!

Phil

 

rmartinez4
8 - Asteroid

The issue is that I don't have a space between the time and date to use the text to columns.

2022-08-1713:15:46GMT No space
2022-08-1714:50:01GMT No space
2022-08-1706:30:06GMT No space

DataNath
17 - Castor
17 - Castor

If your data is a consistent structure then you could just use Substring() functions based on the position of where the 2 elements will split:

 

DataNath_0-1660850791901.png

DavidSkaife
13 - Pulsar

Hi @rmartinez4 

 

An alternative way is to use Regex for the time:

 

DavidSkaife_0-1660850780117.png

 

Maskell_Rascal
13 - Pulsar

Hi @rmartinez4 

 

Thank you for the additional information. If there is no space between Date and Time, you can still convert the Date/Time to a Date since its the beginning of the field it will strip out the remaining when converting. You can then use something like Substring or Right functions to get the remaining part split. 

 

Here is an example of where I did it with formulas and converted them at the same time. 

Maskell_Rascal_0-1660852015442.png

 

If you need the GMT portion of it in Time, just omit the DateTimeParse part of the formula. 

 

Cheers!

Phil

rmartinez4
8 - Asteroid

Hi Phil,

 

Since I have your attention. : )

 

Will you help me separate this 24Jun202202:52AMGMT-0400 with this format.

 

Thank You,

Maskell_Rascal
13 - Pulsar

@rmartinez4 

 

Is the -0400 important in the conversion? Typically that is used to show the time offset from GMT. If that's needed, there is most likely some more we can do to account for it. If its not needed, then the below formula will work. 

DateTimeParse([Field1],'%d%b%Y%I:%M%p')

 

This turns that date/time into the following:

Maskell_Rascal_0-1660858380290.png

 

While this is in just one field now, you can use some additional parsing to get them into separate fields if needed. Something like the below:

Maskell_Rascal_1-1660858582141.png

 

If there are continued inconsistencies in your date/time fields, you can write some logic to catch them and apply each desired format/parsing. 

 

Hope this helps.

 

Cheers!

Phil

 

 

 

rmartinez4
8 - Asteroid

Not needed. Thank you for all your help.

Labels
Top Solution Authors