DATE_FORMAT do?DATE_FORMAT formats a date or datetime value into a string based on a specified pattern. It helps you display dates in a readable or custom way.
EXTRACT?EXTRACT pulls out a specific part (like year, month, day) from a date or time value. It returns that part as a number.
DATE_FORMAT to show a date as 'Day-Month-Year'.Example: DATE_FORMAT('2024-06-15', '%d-%m-%Y') returns '15-06-2024'.
EXTRACT?Use EXTRACT(MONTH FROM date_column). It returns the month number (1 to 12).
DATE_FORMAT and EXTRACT?DATE_FORMAT converts a date to a formatted string. EXTRACT gets a numeric part from a date (like year or day).
EXTRACT(YEAR FROM date) returns the year as a number. The others are incorrect or invalid.
DATE_FORMAT('2024-06-15', '%d/%m/%Y') return?The format %d/%m/%Y means day/month/year, so it returns '15/06/2024'.
EXTRACT NOT get from a date?EXTRACT can get numeric parts like YEAR, MONTH, HOUR but not text like weekday name.
DATE_FORMAT formats dates into readable strings like 'June 15, 2024'.
EXTRACT return?EXTRACT returns a number representing the part of the date (like month number).
DATE_FORMAT to change the display of a date.EXTRACT helps when working with dates in SQL.