Sep 18, 2020 5:36 pm
how to use sql date format dd mm yyyyy or sql date format yyyymmdd
2 Replies
Sep 18, 2020 8:39 pm
select last_name, hire_date
from employees
where to_char(hire_date,'yyyy') >2005
Sep 19, 2020 7:59 am
Let us consider the simple calendar table for this example SQL date format dd mm yyyy and date format YYYYMMDD examples.
date format ddmmyyyy
Calander
date
25-02-2020:00:00:0000
Select FORMAT(date,'dd-MM-yyyy') from calendar
Here date is a column name in the calendar table
It returns date something like 25-02-2020 for date format ddmmyyyy.
Select FORMAT(date,'yyyy-MM-dd') from calendar
Returns 2020-02-25 for date format yyyymmdd
I can also ignore a specific format something like below.
Select FORMAT(date,'yyyy-MM') from calendar
Returns 2020-02