Results 1 to 3 of 3

Thread: Date Problems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    23

    Date Problems

    HI

    i am using the Date Time Control Picker

    i have set the format as being short

    and i have two set of dates , i wish to find the number of weeks between the two set of dates ?? how do i do that

    for eg ?

    date 1 : 01/04/2004

    date 2 : 22/04/2004

    i should get a result of 3 weeks

    How do i go about to do that ?
    can anyone help me plz ?

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Here is an example , I knocked up .
    VB Code:
    1. Private Sub test()
    2.  
    3.         Dim StartDate As New Date(2004, 4, 1)
    4.         Dim EndDate As New Date(2004, 4, 22)
    5.         Dim span As TimeSpan = EndDate.Subtract(StartDate)
    6.         StartDate.Subtract(StartDate)
    7.  
    8.         Dim NumberOfDays As Integer = span.Days
    9.  
    10.         Select Case NumberOfDays
    11.             Case 0 To 7
    12.                 MessageBox.Show("One week ago")
    13.             Case 7 To 15
    14.                 MessageBox.Show("Two weeks ago")
    15.             Case 15 To 23
    16.                 MessageBox.Show("Three weeks ago")
    17.             Case 23 To 30
    18.                 MessageBox.Show("Four weeks ago")
    19.         End Select
    20.  
    21.     End Sub

  3. #3
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    or, look into the DateDiff Function

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