I would like to know if it is possible to have 2 formats of dates inside one column.
The problem is that I need to have a default value if the table is NULL which is a date, and if the table is NOT null then i would need just a timestamp.
I've made a CASE that should do this, but it won't work.
CASE WHEN s.time IS null
THEN
TO_DATE('01-JAN-1901 01:00:00', 'dd-MON-yyyy HH24:MI:SS')
ELSE
TO_DATE(s.time, 'HH24:MI:SS')
END AS time
That statement gives me "ORA-01858: a non-numeric character was found where a numeric was expected."
If i try something like this:
CASE WHEN s.time IS null
THEN
TO_DATE('01-JAN-1901 01:00:00', 'dd-MON-yyyy HH24:MI:SS')
ELSE
TO_DATE(TO_CHAR(s.time, 'HH24:MI:SS'), 'HH24:MI:SS')
END AS time
It will work, however it will add a date in front of the time - and it will look like this: (i don't know where it is getting that date from 01-JUL-2013)
TIME
-------
01-JAN-1901 01:00:00
01-JUL-2013 15:35:00
instead of this:
TIME
-------
01-JAN-1901 01:00:00
15:35:00
(this is what i want)