Find the Next or Previous Workday

Started by sukishan, Sep 04, 2009, 10:18 PM

previous topic - next topic
Go Down

sukishan

Find the Next or Previous Workday

Function dhNextWorkday(Optional dtmDate As Date = 0, _
Optional rst As Recordset = Nothing, _
Optional strField As String = "") As Date
    ' Return the next working day after the specified date.
    Dim dtmTemp As Date
    Dim strCriteria As String
    If dtmDate = 0 Then
        ' Did the caller pass in a date? If not, use
        ' the current date.
        dtmDate = Date
    End If
    dhNextWorkday = SkipHolidays(rst, strField, dtmDate + 1, 1)
End Function
Function dhPreviousWorkday(Optional dtmDate As Date = 0, _
Optional rst As Recordset = Nothing, _
Optional strField As String = "") As Date
    Dim dtmTemp As Date
    Dim strCriteria As String
    If dtmDate = 0 Then
        ' Did the caller pass in a date? If not, use
        ' the current date.
        dtmDate = Date
    End If
    dhPreviousWorkday = SkipHolidays(rst, strField, _
     dtmDate - 1, -1)
End FunctionIf you want to find the first or last workday in a given month, all you need to do is maneuver to the first or last day in the month and then skip holidays forward or backward. For example, the dhFirstWorkdayInMonth function, shown in Listing 2.11, handles this for you. The function accepts the same three optional parameters as the previous examples.

The dhFirstWorkdayInMonth function first finds the first day in the month, using the same code as in other procedures in this chapter. Once it gets to the first day, it calls SkipHolidays, passing the recordset, the field name, the starting date, and the increment (1, in this case). The date returned from SkipHolidays will be the first working day in the month.
A good beginning makes a good ending

pradeep prem

in this function we can easily get for first or last work day in month

i can easy get from this function

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:
Verification:
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview
IT Acumens Web Design Chennai | GinGly :: Mobile SMS Backup | CineBuzz :: Latest Cinema News | My Kids Diary :: Kids magical moment :: Book domain name @ 99 Rs monthly
Copyright 2005 - 2019 :: IT Acumens :: All Rights Reserved.
ITAcumens Forum with 2 lakhs post running for 14 years - Powered by IT Acumens Dedicated Server