|
-
Feb 18th, 2008, 11:34 PM
#1
Thread Starter
New Member
Get dates between dates
I have a start date of: 02/13/2008 17:06
I have an end date of: 02/16/2008 23:49
I have been reading and reading but have no solution. I have two dates, a start and an end, which I have put at the top. How can I populate a listbox with the first item being the starting date and the last item being the end date and all items inbetween are dates and times incrementing in 1 minute values...?
ie:
02/13/2008 17:06
02/13/2008 17:07
02/13/2008 17:08
02/13/2008 17:09
... all the way to
02/16/2008 23:49
ANY HELP IS GREATLY APPRECIATED!!!
-
Feb 18th, 2008, 11:38 PM
#2
Re: Get dates between dates
vb.net Code:
Dim time As Date = startDate Do myListBox.Items.Add(String.Format("{0:d} {0:HH:mm}", time)) time = time.AddMinutes(1) Loop Until time > endDate
Note that that format creates a string containing the standard short date form for the system, followed by a space, followed by hours and minutes in 24 hour format.
-
Feb 18th, 2008, 11:39 PM
#3
Re: Get dates between dates
A quick Google search yielded the members of a DateTime object. It includes a method called AddMinutes.
Sounds like you can declare your start time, add 1 minute then add to the ListBox until it reaches the ending time. All that is required is a simple While loop.
-
Feb 18th, 2008, 11:45 PM
#4
Thread Starter
New Member
Re: Get dates between dates
thank you so much... my brain always wants to make it complicated and here it is being the easiest!!!
-
Feb 18th, 2008, 11:53 PM
#5
Re: Get dates between dates
The critically important first step is to ask yourself what you would do if you had to do the same thing manually, with pen and paper. The algorithm should be the same and implementing a simple algorithm is generally simple.
-
Feb 19th, 2008, 12:23 AM
#6
Re: Get dates between dates
 Originally Posted by if_then_else
thank you so much... my brain always wants to make it complicated and here it is being the easiest!!!
No problem. Thanks for giving me a disapproval rating 
heh
-
Feb 19th, 2008, 01:18 AM
#7
Re: Get dates between dates
 Originally Posted by kasracer
No problem. Thanks for giving me a disapproval rating
heh
That's the pain you suffer when you point people to where they could have answered their question for themselves. I've felt it many times.
-
Feb 19th, 2008, 02:06 AM
#8
Thread Starter
New Member
Re: Get dates between dates
i gave everybody an approval? will do again, maybe i clicked wrong... my bad... i thought i gave everyone an approval rating as you all helped me in superman speed!!! i am a newbie to these forums so please forgive me... i tried to redo the rating but it wont allow...?
Last edited by if_then_else; Feb 19th, 2008 at 02:10 AM.
-
Feb 19th, 2008, 02:34 AM
#9
Re: Get dates between dates
 Originally Posted by if_then_else
i gave everybody an approval? will do again, maybe i clicked wrong... my bad... i thought i gave everyone an approval rating as you all helped me in superman speed!!! i am a newbie to these forums so please forgive me... i tried to redo the rating but it wont allow...?
What's done is done. Just keep kas in mind and give him a couple of positive ratings in the future to make up for it. You can only rate each person 1 in 10, so you'll have to rate 20 people in total to make good. I'm sure kas is worth it though.
-
Feb 19th, 2008, 02:53 AM
#10
Re: Get dates between dates
 Originally Posted by if_then_else
i gave everybody an approval? will do again, maybe i clicked wrong... my bad... i thought i gave everyone an approval rating as you all helped me in superman speed!!! i am a newbie to these forums so please forgive me... i tried to redo the rating but it wont allow...?
No worries. I actually get quite a few disapproval ratings from new members when they tell me I helped them. I think the UI to give ratings is a little confusing to new members. Oh well.
 Originally Posted by jmcilhinney
What's done is done.  Just keep kas in mind and give him a couple of positive ratings in the future to make up for it. You can only rate each person 1 in 10, so you'll have to rate 20 people in total to make good. I'm sure kas is worth it though. 
Heh, thanks. I'm worth all the ratings in the world! (which doesn't say much since ratings are worth $0, heh)
EDIT: According to this thread I'm just a dope and you gave me a positive rating. It just won't show up yet.
Last edited by Kasracer; Feb 21st, 2008 at 11:47 AM.
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
|