CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Timing

  1. #1
    Join Date
    Jan 2008
    Posts
    12

    Timing

    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:
    Code:
    +-----------------------+
    | 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:
    Code:
                        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.

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Timing

    Why are you doing it the hard way????

    Establish a base time. Then use TimeSpan.TotalHours to calculate the delta... no mucking around....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured