Skip to content

Instantly share code, notes, and snippets.

@david-bc
Last active February 1, 2018 19:40
Show Gist options
  • Save david-bc/795f91eebe914957427d62ec601c77fe to your computer and use it in GitHub Desktop.
Save david-bc/795f91eebe914957427d62ec601c77fe to your computer and use it in GitHub Desktop.
const pad = (v, len) => _.padStart(v, len, '0')
const pName = d => `p${d.getFullYear()}${pad(d.getMonth() + 1, 2)}${pad(d.getDate(), 2)}`
const line = d => ` PARTITION ${pName(d)} VALUES LESS THAN (${d.getTime()}),`
let curr = new Date(2018, 0, 1)
_.range(365).map(i => line(new Date(curr.getFullYear(), curr.getMonth(), curr.getDate() + i))).join('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment