Calculate QuaterlyHour from Given two DateTimes in c#

Posted by user281947 on Stack Overflow See other posts from Stack Overflow or by user281947
Published on 2010-05-12T12:36:32Z Indexed on 2010/05/12 13:04 UTC
Read the original article Hit count: 137

Filed under:
|

I want to calculate the quarter Hour from the given two datetimes:

Suppose datetime1 and datetime2 , i am doing somewhat like this :

int d = datetime2.Subtract(datetime1).Hours;

 double l = Math.Round(Convert.ToDouble(d/4));

but if the QuarterHour is 3 (ie d=3), whats the good way to show the output- should it be zero or the round one : 3/4 = 0.75. so should i round up to 1 or 0 is ok. And if round up to 1..how should i?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET