Skip to content

Instantly share code, notes, and snippets.

@edsono
Created January 12, 2011 20:38
Show Gist options
  • Save edsono/776828 to your computer and use it in GitHub Desktop.
Save edsono/776828 to your computer and use it in GitHub Desktop.
Generate DATE values for a year (2012 in example below) in Oracle
SELECT level n, TO_DATE('1/1/' || '2012','DD/MM/YYYY') - 1 + NUMTODSINTERVAL(level,'day') as data
FROM dual
WHERE TO_CHAR(TO_DATE('1/1/' || '2012','DD/MM/YYYY') - 1 + NUMTODSINTERVAL(level,'day'), 'YYYY') = '2012'
CONNECT BY LEVEL <= 366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment