I have dates and wanting to convert dates into month like Jan Feb, I have written the code FORMAT_DATE('%B', DATE(PARSE_DATE ('%m-%d-%Y', Date))) AS month_of_date
Date | Month |
---|---|
1/20/2024 | |
1/21/2024 | |
1/26/2024 | |
2/1/2024 | |
2/2/2024 | |
2/2/2024 |
I need more info regarding the source data type and DBMS you use. But, I assume you have field that has string/varchar data type and want to get the month name using MySQL. Here is the code:
DATE_FORMAT(STR_TO_DATE(Date, '%m/%d/%Y'), '%b') AS Month
For trial running, I have created fiddle link for you.
For MSSQL, you can use:
substring(DATENAME(MONTH,'2024-01-25'), 1,3)
Please only use the tag for the database you are using. Which data type has your date column?
For MySQL, you can use
date_format(your_date,'%b')