Results 1 to 3 of 3

Thread: Date Calculations & Stuff

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    Date Calculations & Stuff

    I am working on a time entry form to interface with an existing accounting package. I need help with a particular calculation.

    The week ending date for a payroll is always on a Saturday, which the program treats as day #7. I have 7 text boxes (Mon - Sun) for entering the time for each day on my form and I have to calculate the date the day falls on as well as the day number.

    I have a few questions to help me get started:
    [list=1][*]Is there a way to make sure a date entered into a text box is always a Saturday? In VBA I could use this If Not IsSaturday(WeekEnding) Then[*]Are there built in intrinsic day numbers? For instance does VB.net treat Monday as a 1 (or whatever number it may be?)[/list=1]

  2. #2
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    Are you looking for something like this:

    VB Code:
    1. Dim tToday As Date = Now.Date
    2. If tToday.DayOfWeek.ToString = "Friday" Then
    ~Peter


  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Date Calculations & Stuff

    For 1st question , You can use this little method (this is the only way I can think of now .)

    VB Code:
    1. Private Sub TodayIS()
    2.  
    3.         Dim dt As New DateTime
    4.         Dim DayNumber As Integer
    5.         DayNumber = dt.Today.DayOfWeek
    6.  
    7.         Select Case DayNumber
    8.             Case 0
    9.                 MessageBox.Show("IT'S Sunday")
    10.             Case 1
    11.                 MessageBox.Show("IT'S Monday")
    12.             Case 2
    13.                 MessageBox.Show("IT'S Tuesday")
    14.             Case 3
    15.                 MessageBox.Show("IT'S Wednesday")
    16.             Case 4
    17.                 MessageBox.Show("IT'S Thursday")
    18.             Case 5
    19.                 MessageBox.Show("IT'S Friday")
    20.             Case 6
    21.                 MessageBox.Show("IT'S Saturday")
    22.         End Select
    23.  
    24.     End Sub


    For 2nd question , this is from MSDN Help :

    The DayOfWeek enumeration represents the day of the week in calendars that have seven days per week. This enumeration ranges from zero, indicating Sunday, to six, indicating Saturday.

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