If I know that the number of days is 331 during the year, how do I convert it to yyyymmdd in PL / SQL?
To convert to DATE:
to_date(331, 'DDD')
You can then format this date, if required, with TO_CHAR.
DECLARE @datetime2 datetime2 = '2007-01-01 13:10:10.1111111' SELECT 'day',DATEADD(day,331,@datetime2)
Another option might be something like this.
select to_char(trunc(sysdate, 'YY') + 331, 'YYYYMMDD') as day from dual