Skip to content

Instantly share code, notes, and snippets.

@syedhassaanahmed
Last active April 28, 2019 20:20
Show Gist options
  • Save syedhassaanahmed/b247acc579b3add2903c107f4b63e60d to your computer and use it in GitHub Desktop.
Save syedhassaanahmed/b247acc579b3add2903c107f4b63e60d to your computer and use it in GitHub Desktop.
Generate comma separated integer days for SQL Server Partition Function
let endDate = datetime(2019-04-28);
range day from endDate - 120d to endDate step 1d
| summarize days = makelist(replace("-", "", substring(day, 0, 10)))
| project array_strcat(days, ", ")
@syedhassaanahmed
Copy link
Author

syedhassaanahmed commented Apr 28, 2019

Output of above query is

20181229, 20181230, 20181231, 20190101, 20190102, 20190103, 20190104, 20190105, 20190106, 20190107, 20190108, 20190109, 20190110, 20190111, 20190112, 20190113, 20190114, 20190115, 20190116, 20190117, 20190118, 20190119, 20190120, 20190121, 20190122, 20190123, 20190124, 20190125, 20190126, 20190127, 20190128, 20190129, 20190130, 20190131, 20190201, 20190202, 20190203, 20190204, 20190205, 20190206, 20190207, 20190208, 20190209, 20190210, 20190211, 20190212, 20190213, 20190214, 20190215, 20190216, 20190217, 20190218, 20190219, 20190220, 20190221, 20190222, 20190223, 20190224, 20190225, 20190226, 20190227, 20190228, 20190301, 20190302, 20190303, 20190304, 20190305, 20190306, 20190307, 20190308, 20190309, 20190310, 20190311, 20190312, 20190313, 20190314, 20190315, 20190316, 20190317, 20190318, 20190319, 20190320, 20190321, 20190322, 20190323, 20190324, 20190325, 20190326, 20190327, 20190328, 20190329, 20190330, 20190331, 20190401, 20190402, 20190403, 20190404, 20190405, 20190406, 20190407, 20190408, 20190409, 20190410, 20190411, 20190412, 20190413, 20190414, 20190415, 20190416, 20190417, 20190418, 20190419, 20190420, 20190421, 20190422, 20190423, 20190424, 20190425, 20190426, 20190427, 20190428

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment