date format
Options
Riaan Backer
Member ✭
Hi Xano Team
I have a date value 20211205(YYYYmmdd) which is a text value which I need to convert to a date format. I used the format_timestamp but the function does not know that the text value is in format (YYYYmmdd) and therefore returns a completely wrong date (1970-01-01T07:36:51+02:00)
The only way I can get this working is to substring the YYYY, the mm and then dd into 3 different variables and once this is done to concat the values to get it into a format like YYYY-mm-dd which then returns the correct results. Can you please confirm if there is a quicker and more effective way of achieving this.
I have a date value 20211205(YYYYmmdd) which is a text value which I need to convert to a date format. I used the format_timestamp but the function does not know that the text value is in format (YYYYmmdd) and therefore returns a completely wrong date (1970-01-01T07:36:51+02:00)
The only way I can get this working is to substring the YYYY, the mm and then dd into 3 different variables and once this is done to concat the values to get it into a format like YYYY-mm-dd which then returns the correct results. Can you please confirm if there is a quicker and more effective way of achieving this.
Comments
-
Here show the options for convert text to date:
https://docs.xano.com/working-with-data/timestamp#what-are-my-options-for-inputting-a-timestamp-into-xano-through-the-api
Try to convert your text value 20211205 to ISO 8601 without time (2021-11-05) and the use "to_timestamp" filter.
[image.png]
-
A more complete solution, taking any text_date in yyyymmdd and returning a date:
[image.png][image.png] -
- thanks for your assistance. My question relates to if there are not an quicker way to get the text field into ISO format. I did something very similar to your solution. I am processing over 5000 records at a time and this will add overhead to the solution hence my question.
-
did you already experienced performance issues? I don't know the inner workings of Xano, but I think it's pretty basic processing...
-
I am busy testing this but I just want to ensure my logic is implemented in the most efficient way
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