Assume I have a DateTime:
DateTime datetime(2013,11,08,17,45,23,300);//2013:11:08 17:45:23:300
I want to truncate this DateTime by differenct accuracy and return the minimum DateTime like this:
Year: 2013:01:01 00:00:00:000
Quarter: 2013:10:01 00:00:00:000 //Oct is first month of that quarter
Month: 2013:11:01 00:00:00:000
Week: 2013:11:03 00:00:00:000 // 3rd is Sunday of that week
Day: 2013:11:08 00:00:00:000
Hours 2013:11:08 17:00:00:000
Minute: 2013:11:08 17:45:00:000
Second: 2013:11:08 17:45:23:000
I know you can do it by changing different part of the DateTime, is there a better way to do it? or is there already a build in function in .net which I don't know?