GET the Number of days list from weeks span

ddp2307

New member
Joined
Apr 21, 2006
Messages
3
Programming Experience
Beginner
Hi
How can i get the Date's list from provided weeks time span, meaning
If i provide 6 weeks as timeSpan then i should get the list of dates backward from the Current Date as

If current Date as 26 April 2006
then i should get list as
26 April, 25April ,24April,23April,22April,21April............... up to 6 weeks. Back word and also
Forward from current Date.
Thanks in advance
Ddp
 
how about this?
VB.NET:
Sub dateslist()
  Dim weeks As Integer = 6
  Dim ts As New TimeSpan(weeks * 7, 0, 0, 0)
  Dim datesforward As New ArrayList
  Dim datesbackward As New ArrayList
  Dim dtfw As Date = Date.Now
  Dim dtbw As Date = Date.Now
  For i As Integer = 1 To ts.Days
    datesforward.Add(dtfw.Date)
    datesbackward.Add(dtbw.Date)
    dtfw = dtfw.AddDays(1)
    dtbw = dtbw.AddDays(-1)
  Next
 
  'let's have a look
  Dim sb As New System.Text.StringBuilder
  For Each dt As Date In datesforward
    sb.Append(dt.ToLongDateString)
    sb.Append(vbNewLine)
  Next
  MsgBox(sb.ToString)
  sb = New System.Text.StringBuilder
  For Each dt As Date In datesbackward
    sb.Append(dt.ToLongDateString)
    sb.Append(vbNewLine)
  Next
  MsgBox(sb.ToString)
End Sub
 
Back
Top