Monthly Archives: November 2013

SQL Server: Divide Date Range into Months

I wrote a script the other day that is utterly useless to me, but it might be helpful for someone else, so I thought I’d write a quick post about it.

Suppose you have some date range, let’s say “1/20/2013 – 4/29/2014”. Now, suppose you want this range to be broken up into one month sections, with a start and end date for each month. Suppose, for some reason, you want to use a recursive common table expression (CTE). You can just do this:

This would produce the following results:


I think that this is actually pretty cool, but I can’t really come up with a reason to use something like this, outside of maybe a financial application. Anyway, I hope someone gets some use out of it.

Points Calculator 1.1 Released

I just released Points Calculator v1.1 on the “Things I Work On” page. It uses a well-known points-based weight loss formula to calculate how many “points” a particular food is worth. I used to use it in college, and I haven’t really messed with it since then, but I figured I would put it up here in case anyone can use it. It’s also open source if you want to check out how it was made. No real magic there though, just a simple button event and an equation. Anyway, enjoy.