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')
04-09-2024 06:34 PM - edited 04-09-2024 06:35 PM
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!
04-09-2024 11:33 PM
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 a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group