07-18-2022 08:33 AM
Hi,
I have a date column in a delta table called ADate. I need this in the format YYYYMMDD.
In TSQL this is easy. However, I can't seem to be able to do this without splitting the YEAR, MONTH and Day and concatenating them together.
Any ideas?
07-18-2022 06:46 PM
@Lloyd Vickery could you please share a sample of what date looks like in your delta table and desired output?
07-19-2022 06:26 AM
https://community.databricks.com/s/question/0D58Y00008xpCB8SAM/convert-date-to-yyyymmdd-in-databrick... this might be helpful. let me know @Lloyd Vickery
09-05-2022 03:20 AM
Hello @Lloyd Vickery
Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.
We'd love to hear from you.
Thanks!
01-11-2023 09:12 AM
Hello,
You can use the function date_format(your_date_column, 'yyyyMMdd')
4 weeks ago - last edited 4 weeks ago
I'll share I'm having a variant of the same issue. I have a varchar field in the form YYYYMMDD which I'm trying to join to another varchar field from another table in the form of MM/DD/YYYY. Does anyone know of a way to do this in SPARK SQL without splitting the YEAR, MONTH and Day and concatenating them together? I've tried date_format, to_date, date, cast, and to_timestamp functions or different combinations of them, but haven't yet succeeded. Any help is appreciated. Thanks!
4 weeks ago
basically with to_date() and date_format() you can play with dates all you want.
to_date converts a string to a date (with the format the datestring is in as a parameter), and date_format converts a date to a string (with the format the output has to be in as a parameter).
Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections.
Click here to register and join today!
Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.