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

Alteryx designer Discussions

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

parsing to get date to always opening latest file

Meteoroid

Hi,

I have a HTML path which I managed to parse down to below data.

Data format is filename and date timestamp.

 

file-20190813-180331.csv
file-20190814-115531.csv

file-20190814-115603.csv
file-20190814-115619.csv

 

How can I now parse it so that I will always be selecting the most recent file.

 

Thanks

Jax

Alteryx Certified Partner

Hey @Jax23 

 

DateTimeParse([Field1],"file-%Y%m%d") will strip the date from the file name, then sort descending 

Highlighted
Pulsar

Hi @Jax23 

Tested this out with your data, and it worked. Use a Sort tool after this data list, and sort decsending on that date time field, This will put the latest on top, even though they are text fields. Then use a sample tool to select just the first record.

 

Let me know if that helps.

 

Cheers!

Esther

Meteoroid
Thanks Ester. Dint know you can sort it right away. I tried LordNeilLord's method but it didn't work. Not in descending order even though I sorted it, very odd.
Asteroid

Hey @Jax23 ,

 

I came up with this solution for you. Parse the date/time from the filename and sort it by reverse order then select the first record. You will always select the most recent file:

jax.png

Hope this helps!

-Ed

 

Labels