MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Solved

Posted on 1998-08-12

I am creating a service report and the users have to enter in the time they started

to the time they finished and I want to calculate the amount of hours they have

worked. The method I am using seems to work the odd time but I am having

trouble getting it to work all the time. I am using double variables and I am not

sure if I should be using them. I am also changing the time into 24 hr clock if the

starttime is larger than the endtime.

eg. starttime 11.00 endtime 2.00->14.00

This works all the time but it is when you subtract the time such as 1.15 to 2.00,

you get 0. 45 but I want it to be .75 because you have worked 3/4 of an hour. I

am only doing it in 15 minute intervals so I didn't think it woul be that difficult. This

is how I am doin it.

if (m_hourswork==0.45) //45 minutes worked

m_hourswork=0.75;

if m_hourswork==0.15) //15 minutes worked

m_hourswork=0.25)

I do this for all 15 min intervals and every hour upto 10 hours because no one will

work more than 10. The method I am using seems to work from time to time so I

think it may be the 'double' varibles I am using.

Thank You for the help!!

Greatly Needed

to the time they finished and I want to calculate the amount of hours they have

worked. The method I am using seems to work the odd time but I am having

trouble getting it to work all the time. I am using double variables and I am not

sure if I should be using them. I am also changing the time into 24 hr clock if the

starttime is larger than the endtime.

eg. starttime 11.00 endtime 2.00->14.00

This works all the time but it is when you subtract the time such as 1.15 to 2.00,

you get 0. 45 but I want it to be .75 because you have worked 3/4 of an hour. I

am only doing it in 15 minute intervals so I didn't think it woul be that difficult. This

is how I am doin it.

if (m_hourswork==0.45) //45 minutes worked

m_hourswork=0.75;

if m_hourswork==0.15) //15 minutes worked

m_hourswork=0.25)

I do this for all 15 min intervals and every hour upto 10 hours because no one will

work more than 10. The method I am using seems to work from time to time so I

think it may be the 'double' varibles I am using.

Thank You for the help!!

Greatly Needed

2 Comments

if( ( m_hourswork - 0.45 ) < 0.001 ) // 45 minutes worked

m_hourswork = 0.75.

I must say though that this is a really clumsy way of approaching your problem. MFC has some wonderful time handling functions. Why don't you check the CTime class?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Title | # Comments | Views | Activity |
---|---|---|---|

How do you programatically show and hide the Windows 10 On-Screen-Keyboard? | 3 | 785 | |

countEvens challenge | 2 | 111 | |

zeroFront challenge | 7 | 111 | |

building a service to accessed via telnet client, want colors ? | 4 | 92 |

Join the community of 500,000 technology professionals and ask your questions.