Search code examples
sqloracle-databasedatedate-arithmeticdate-conversion

Convert a number of day into a date


Is it possible to convert a day of the year number to a date?

For example, in oracle I can get the day of the year number by:

Select to_char(sysdate,'ddd') as "y_num_day" from dual;

I would need the reverse to perform some date arithmetic.


Solution

  • To convert it back to a date, use to_date

    select to_date(to_char(sysdate,'ddd'),'ddd') as "date" from dual
    

    List of valid parameters for to_date