Help me to populate below columns as date without using to_date or to_char functions.
day | month | year |
---|---|---|
1 | 2 | 1995 |
2 | 3 | 1998 |
5 | 6 | 2020 |
output
date |
---|
01-02-1995 |
02-03-1998 |
05-06-2020 |
Help me to populate below columns as date without using to_date or to_char functions.
day | month | year |
---|---|---|
1 | 2 | 1995 |
2 | 3 | 1998 |
5 | 6 | 2020 |
output
date |
---|
01-02-1995 |
02-03-1998 |
05-06-2020 |
2
Answers
If Oracle, then concatenation of zero left-padded values might do the job (see line #7):
You should use
TO_DATE
as that is what it is designed for.However, as an academic exercise, if you start with
DATE '0001-01-01'
and then use, for Oracle,ADD_MONTHS
(or for MySQL,TIMESTAMPADD
) for the years and months and addition for the days:In Oracle:
Which, for the sample data:
Outputs:
fiddle
Or MySQL:
Which outputs:
fiddle