How to convert daynumber (day nr 331) to yyyymmdd in PL / SQL?

If I know that the number of days is 331 during the year, how do I convert it to yyyymmdd in PL / SQL?

+3
source share
3 answers

To convert to DATE:

to_date(331, 'DDD')

You can then format this date, if required, with TO_CHAR.

+7
source
DECLARE @datetime2 datetime2 = '2007-01-01 13:10:10.1111111'
SELECT 'day',DATEADD(day,331,@datetime2)
0
source

Another option might be something like this.

select to_char(trunc(sysdate, 'YY') + 331, 'YYYYMMDD') as day from dual
0
source

All Articles