'MariaDB converting datetime string to date
Trying CAST() - neither DATE or DATETIME work
Hi, I cannot figure out what I'm doing wrong with trying to convert my varchar column Procedure_Date containing a string in the dd/mm/YYYY hh:mm:ss format. I am trying to extract just the date from this string but I seem to be cursed. Using MariaDB and have gone through all the docs there. Greatly appreciate any advice!
Solution 1:[1]
You can use cast
SELECT Procedure_Date, CAST(STR_TO_DATE(Procedure_Date, '%d-%m-%Y') AS DATE) FROM uniTable5;
Solution 2:[2]
Use: DATE('YOUR DATETIME')
EXAMPLE: DATE('2022-04-25 14:50:01')
OUTPUT: 2022-04-25. Result in DATE.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | LUIS DIEGO CACERES GARCIA |