I'm sure I'm not the first person to need to do this, so I'm looking for the best way.
I've got a set of radio buttons with choices such as
- This Year
- Last Year
- This Month
- Last Month
- This Week
- Last Week
and I need to produce the proper relative date range from the current date (DateTime.Now
).
For example if Last Year
was selected and the current date was 4/2/09 14:45:32
I would need to return a start date of 1/1/08 00:00:00
and end date of 12/31/08 23:59:59
.
Any thoughts?