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

Alteryx Designer Desktop Discussions

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

Date Issue

remarsha
8 - Asteroid


Hi community, from a table with many columns, containing data for many months,  i need to pull out the data for the latest month&Year.

 

The dates (DateTime format) are available in the format as below. How do i pick up the records with the latest Month-Year for .e.g 11 2022

4/2/2020 0:00
4/3/2020 0:00
5/12/2020 0:00
7/6/2020 0:00
5/31/2021 0:00
6/15/2021 0:00
6/22/2021 0:00
6/29/2021 0:00
7/5/2021 0:00
7/7/2021 0:00
7/12/2021 0:00
7/13/2021 0:00
7/20/2021 0:00
7/28/2021 0:00
7/29/2021 0:00
8/2/2021 0:00
8/3/2021 0:00
8/4/2021 0:00
8/5/2021 0:00
8/9/2021 0:00
8/10/2021 0:00
8/11/2021 0:00
8/12/2021 0:00
8/13/2021 0:00
8/17/2021 0:00
8/16/2021 0:00
8/19/2021 0:00
8/23/2021 0:00

11/13/2022 0:00

11/21/2022 0:00
11/10/2022 0:00
11/11/2022 0:00
11/12/2022 0:00

8 REPLIES 8
OllieClarke
15 - Aurora
15 - Aurora

Hi @remarsha 

Firstly parse your datetimes into the proper format (yyyy-mm-dd hh:mm:ss)
Then pull out the year/month using DateTimeTrim([Date],'month')
Then sort Ascending
Then sample the last 1 grouped by year/month

 

Screenshot 2023-07-07 at 09.48.48.png

 

Hope that helps,

 

Ollie

OllieClarke
15 - Aurora
15 - Aurora

@remarsha 
Sorry, if you want to get the records from the latest year month combo, then :

do the same first 2 steps,
Find the max year month

Use a join to just keep the records which match this

Screenshot 2023-07-07 at 09.53.02.png

 

Ollie

 

remarsha
8 - Asteroid

Thanks Ollie. The solution is giving all the dates. I need only to pick up records with the latest month year, in this case its 11-2022. is that possible?

 

OllieClarke
15 - Aurora
15 - Aurora

Hi @remarsha 

My second post has you covered :)

 

Ollie

remarsha
8 - Asteroid

Thanks will test and revert.

Just one Q. You have the taken Field1 as a  'String.'  in the beginning

For the data i have, its ' DateTime'. so do i need to covert it to string first and then follow the steps?

remarsha
8 - Asteroid

i converted the original DateTime to String and followed the steps. It gives the follow error,

ConvError: DateTime (42): DateTime_Out: Cannot convert "2021-12-29 00:00:00" to a date/time with format "%m/%d/%Y %H:%M" and language "English": Month number is out of range 1..12: '2021-12-29 00:00:00' Record #7

 

remarsha
8 - Asteroid

Hi Ollie, the second solution worked. Thank you very much. 

OllieClarke
15 - Aurora
15 - Aurora

Hi @remarsha 

I parsed the datetimes into the proper format based on your post. If you already have datetimes, then you can ignore the parsing part of the process, and start at the datetimetrim()

 

Ollie

Labels