VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Function to return previous Friday's date based on current date.

by Emeraldjim (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 26th November 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Function to return previous Friday's date based on current date.

API Declarations


'This code could be adjusted to return any previous day of the week. It
'returns the current date if function is called on a Friday but could be
'adjusted to return the previous Friday's date.

Rate Function to return previous Friday's date based on current date.




'Declare variables
Dim intStartDay As Integer

'Calculate previous Friday as status date if today is not Friday.
intStartDay = WeekDay(dteStatus)

Select Case intStartDay
    Case 1
        LastFriday = Date - 2
    Case 2
        LastFriday = Date - 3
    Case 3
        LastFriday = Date - 4
    Case 4
        LastFriday = Date - 5
    Case 5
        LastFriday = Date - 6
    Case 6
        'Add " - 7" to next line for previous Friday.
        LastFriday = Date
    Case 7
        LastFriday = Date - 1
End Select

End Function

Download this snippet    Add to My Saved Code

Function to return previous Friday's date based on current date. Comments

No comments have been posted about Function to return previous Friday's date based on current date.. Why not be the first to post a comment about Function to return previous Friday's date based on current date..

Post your comment

Subject:
Message:
0/1000 characters