Click to See Complete Forum and Search --> : Timing


evios
June 11th, 2008, 09:17 PM
OK, i do my best effort to explain this:
Lets say now inside my database has one field of name='TEX' and it looks like this:

+-----------------------+
| TEX |
+-----------------------+
| 75 2008/05/15 02:35 |
| 77 2008/05/15 02:47 |
| 77 2008/05/15 02:47 |
| 77 2008/05/15 02:47 |
| 77 2008/05/16 02:47 |
| 77 2008/05/16 02:47 |
| 77 2008/05/16 02:47 |
| 75 2008/05/15 02:27 |
| 75 2008/05/16 02:27 |
| 77 2008/05/15 02:47 |

the two digits on the leftmost denote the machine ID, while the date and time on the right showing the time that particular item has been pass through this machine. For example, 75 2008/05/15 02:35 means the item pass through machine ID 75 at time 2008/05/15 02:35.
Now i need to categorize it. In ASP.NET, lets say user want to view data from 2008/05/15 12:00:00 to 2008/05/16 12:00:00. Then i need to show them on that particular 2008/05/15 12:00:00, on machine 75,76,77,78, there are how much items being allocated to them according to hour. Like:
2008/05/15 12:00:00 For Machine 75: 89
2008/05/15 12:00:00 For Machine 76: 23
2008/05/15 12:00:00 For Machine 77: 45
2008/05/15 12:00:00 For Machine 78: 88
.....
It goes by hour here.
I'd settled everything, but now i face one critical problem. Look at what user has chosen to view:
2008/05/15 12:00:00 to 2008/05/16 12:00:00
I used the code shown below:

If vDateTime.Hour >= 0 And vDateTime.Hour < 24 Then
Dim hour As Integer = vDateTime.Hour
If hour = 0 Then
hour = 24
End If

That means, once it see hour=12:00:00, it will be allocated to hour=12 and so on. How if yesterday 12:00:00 and todays 12:00:00? They had been throw to the same hour but actually are of different date. This is what i am facing now. I need to separate the date as well if 2 dates have been chosen.

Thanks.

TheCPUWizard
June 11th, 2008, 09:28 PM
Why are you doing it the hard way????

Establish a base time. Then use TimeSpan.TotalHours to calculate the delta... no mucking around....