|
-
June 22nd, 2008, 11:08 PM
#1
[Urgent] Timing Allocation Problem
Lets say i do this to count the number of that particular hour:
Code:
If vDateTime.Hour > 0 And vDateTime.Hour < 24 Then
Dim hour As Integer = vDateTime.Hour
If hour = 0 Then
hour = 24
End If
count(hour, 0) = count(hour, 0) + 1
Refer to the data below:
1.2008/06/24 02:00
2.2008/06/24 12:00
3.2008/06/24 06:00
4.2008/06/24 17:00
5.2008/06/25 06:00
The first will be allocated to hour=02 and the second one will go to hour=12.
However i face this problem: How if 3 and 5 having the same hour but different date? I need to get the date as well. Can i solve this problem using almost the same coding format above? I need to keep count(hour, 0) = count(hour, 0) + 1 this way. Thanks a lot.
-
June 22nd, 2008, 11:17 PM
#2
Re: [Urgent] Timing Allocation Problem
You should always parse the date, rather than the hour, but you can also use DAY()
http://msconline.maconstate.edu/tuto...bnet01-07.aspx
-
June 23rd, 2008, 10:01 PM
#3
Re: [Urgent] Timing Allocation Problem
Now i already simplify my coding to the format below:
I need to allocate the 24-hour time selected by the user to an array of size 24, for example, If the user choose 2day 8AM until tomorrow 7AM, Then my idea is:
hourarray(0)=8AM
hourarray(1)=9AM.....
..hourarray(23)=7AM...
How can i loop it? Thanks
-
June 24th, 2008, 01:19 AM
#4
Re: [Urgent] Timing Allocation Problem
your fields ahould be date/time. you can use a function to change it to hour minute or second
-
June 24th, 2008, 06:34 AM
#5
Re: [Urgent] Timing Allocation Problem
Okay ..
Look up DateDiff function.. and set up your code to do something alond the lines of ...
1) Get start date and time..
2) read in DATA ..(first/Next record)
3) Compare data(2) to start date (1) and skip all data before start date (go back to 2)
4) Get the Datediff of data(2) date and start date(1)
5) if Datediff day = 1 (more than 24 hours) go back to 2..
6) do your count...
Hope this Helps...
Gremmy...
6)
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
June 24th, 2008, 08:17 AM
#6
Re: [Urgent] Timing Allocation Problem
Why VB6 style solutions in the VB.NET forum...
Simply use DateTime and TimeSpan...problems all solved with no explicit parsing or even calculating....
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|