Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
After trying Google and some other posts on here, I can not seem to find the answer.
I currently have dates stored in MYSQL as YYYY-mm-dd but for the ACF Date Picker in Wordpress it reads dates as yyyymmdd.
How can I convert the current format to the new format? All the other conversions seem to want it to have dashes but I was to take them away.
Dates are stored in the database using an internal format. To convert them to a string, use the
date_format()
function:
select date_format(col, '%Y%m%d')
If the dates are stored as strings, then just use replace()
:
select replace(col, '-', '')
You can write views over the tables, if you don't want to do this every time you select from the tables.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.