Converting number to date in oracle

后端 未结 1 1167
暗喜
暗喜 2021-01-20 20:21

I have a numeric field in my Oracle database that represents the number of days since Dec 28, 1800. However I am trying to select it (for another application) as the current

相关标签:
1条回答
  • 2021-01-20 20:59

    Firstly, get this out of the way, your life would be easier if you stored dates in a date data-type.

    However, to answer your question to add days to a date in Oracle you can use the + operator.

    Firstly though you have to have a date so I'll convert the 28th December 1800 into a date using to inbuilt to_date function then add the number. In your case you would want:

    select to_date('1800/12/28','yyyy/mm/dd') + 77650 from dual
    

    I've set up a little SQL Fiddle to demonstrate for you.

    0 讨论(0)
提交回复
热议问题