Trouble with an Array of dates
Options
![Simon Parslow](https://us.v-cdn.net/6037124/user_avatars/3378931.jpg)
Simon Parslow
Member ✭
hello
I have the following returned array:
[
05/03/2009,
03/02/2022,
30/09/2020,
25/10/2021,
11/01/2022,
02/02/2022,
01/02/2021,
01/02/2022,
25/10/2021
]
I am trying to extract the oldest date from the array.
I have not been successful using the sort function. Not sure there is a native date sorting function?
I have tried to loop through to change the dates to timestamp, however for some reason the third date 30/09/2020 throws an error for the totimestamp function, I'm not sure why.
Any advice on the best way to get the oldest date out?
Many thanks.
/
I have the following returned array:
[
05/03/2009,
03/02/2022,
30/09/2020,
25/10/2021,
11/01/2022,
02/02/2022,
01/02/2021,
01/02/2022,
25/10/2021
]
I am trying to extract the oldest date from the array.
I have not been successful using the sort function. Not sure there is a native date sorting function?
I have tried to loop through to change the dates to timestamp, however for some reason the third date 30/09/2020 throws an error for the totimestamp function, I'm not sure why.
Any advice on the best way to get the oldest date out?
Many thanks.
/
Comments
-
Ok I made it work.
The reason the 3rd date was causing an error converting to a timestamp is because the date format wasn't recognized, it wanted to see the format m/d/Y instead of what my array had d/m/Y.
So I used substr and concat to re format the date, and then the conversion to timestamp worked fine.
I then created a new array made up of the time stamp values. And sorted them into an ascending list.
Then I removed the first value from the list, stored it as a variable and then formatted this back to d/m/Y for my output of the oldest date.
If anyone knows a better way please let me know as I learning (fast).
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback