Results 1 to 4 of 4

Thread: SOLVED: Check if a Date is on the Weekend & Skip

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2010
    Posts
    58

    SOLVED: Check if a Date is on the Weekend & Skip

    Hello, I have a script that needs to only carry out and action if the day is not a weekend. Could somebody assist with this code?


    Code:
    1. Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.  
    3.         'convert date1 to a string
    4.         Dim StartDate As Date = DateTimePicker1.Value
    5.         Dim StartDateStr As String
    6.  
    7.         'get date2
    8.         Dim EndDate As Date = DateTimePicker2.Value
    9.  
    10.         'get the number of days between date1 and date2
    11.         Dim intDays As Integer = EndDate.Subtract(StartDate).Days()
    12.         Dim i As Integer
    13.  
    14.             For i = 0 To intDays
    15.  
    16.                       'Check If StartDate is a not a weekend
    17.                      
    18.                       'if it is not a weekend
    19.                             'Do code
    20.  
    21.                       Else
    22.                      
    23.                       EndIf
    24.  
    25.                 StartDate = StartDate.Date.AddDays(1D)
    26.             Next
    27.  
    28.     End Sub
    Last edited by Eksbee; Feb 18th, 2010 at 11:59 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
  •  



Click Here to Expand Forum to Full Width