1

Let's suppose I have an interval. Say 15 minutes.

I have a start time of 13:57 and an end time of 15:17.

The time when this process runs happens to be 14:07.

I want the result to be 14:00,14:15,14:30,14:45,15:00,15:15 while retaining the year/month/date, etc.

So far, I have these facts down. The minutes modulo the interval is always zero. I need to count down from the current time until I hit the first mod-zero number which is 14:00.

I then simply increase that number by the interval until I reach my ceiling. My real question is how to come up with an elegant, simple way to find this first floor number.

The interval is a timespan and the other two values are datetimes.

Any ideas?

tylerjgarland
  • 643
  • 6
  • 19

1 Answers1

1

You can calculate the minute for the first result instance like:

m: current time's minute 
new minute part: m - (m % interval)
kaptan
  • 3,060
  • 5
  • 34
  • 46
  • Thanks a ton! After thinking about it for about 30 minutes, I hit myself on the head because I had forgotten about modulus. It's what I ended up using. – tylerjgarland Nov 22 '13 at 22:28