Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi,
 
How to get the days names between two dates in vb.net.
 
Ex- Fromdate(7/16/2012)
Todate(7/22/2012)
 
OutPut
7/16/2012
7/17/2012
7/18/2012
7/19/2012
7/20/2012
7/21/2012
7/22/2012
 
Like that..
I need to assign those dates into textboxes...
 

Thanks in advance
Sucharitha
Posted 31-Jul-12 19:55pm
Edited 31-Jul-12 20:49pm
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this:
 
Dim startDay As Date
        Dim endDay As Date
        startDay = New Date(2012, 7, 16)
        endDay = New Date(2012, 7, 22)
        Dim dayCtr As Date
        dayCtr = startDay
        Do While (dayCtr <= endDay)
            MessageBox.Show(dayCtr.Date.Day & "-" & dayCtr.Date.DayOfWeek.ToString())
            dayCtr = dayCtr.AddDays(1)
        Loop
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Please can any body give me the code
No. It does not work like this here.
 
Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it's not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.
 

Read about: DayofWeek property exposed by DateTime structure.
Refer:
DateTime.DayOfWeek Property[^]
MSDN: DateTime Structure[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Please can any body give me the code
No. It does not work like this here.
 
Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it's not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.
 

Read about: DayOfWeek property exposed by DateTime structure.
Refer:
DateTime.DayOfWeek Property[^]
MSDN: DateTime Structure[^]
  Permalink  
Comments
RagSuchi at 1-Aug-12 2:49am
   
Hi Sandeep, Thanks for your advice.
n.podbielski at 20-Nov-12 3:55am
   
I was curious way this question has many answers. Yourself added 2 :) But seriously, your advice is pointless since he got code in other answers :sigh:
Sandeep Mewara at 20-Nov-12 4:56am
   
It was a bug reported to CP about duplicate answers getting posted at times. This being one of those cases. Thanks for pointing. Removed. UPDATE: Well, unable to delete currently. "Unexpected error during delete attempt. Please try again later." Will delete one of the duplicates later.
n.podbielski at 20-Nov-12 5:16am
   
No wories, just saying :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

gives the dates in loop
 
        Dim startDay As Date
        Dim endDay As Date
        startDay = TextBox12.Text
        endDay = TextBox13.Text
        Dim dayCtr As Date
        dayCtr = startDay
        Do While (dayCtr <= endDay)
            'MessageBox.Show(dayCtr.Date.Day & "-" & dayCtr.Date.DayOfWeek.ToString())
            MessageBox.Show(dayCtr.Date)
            dayCtr = dayCtr.AddDays(1)
        Loop
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,518
1 OriginalGriff 383
2 Manas Bhardwaj 324
3 Tadit Dash 305
4 Peter Leow 255
0 Sergey Alexandrovich Kryukov 9,575
1 OriginalGriff 5,856
2 Peter Leow 4,405
3 Maciej Los 3,540
4 Abhinav S 3,513


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid