thanks bob.
also, i need a date function that will give me the three letter Day abbrev. of a datefield.
im not having luck finding one.
great, thanks again. now, i need to format a 3-letter day abbrev into a number.
i.e. Format(Day_of_week,"#")
Function GetDayNum(strDay As String) As Integer
Select Case strDay
Case "Sun", "Sunday"
GetDayNum = 1
Case "Mon", "Monday"
GetDayNum = 2
Case "Tue", "Tuesday"
GetDayNum = 3
Case "Wed", "Wednesday"
GetDayNum = 4
Case "Thu", "Thursday"
GetDayNum = 5
Case "Fri", "Friday"
GetDayNum = 6
Case "Sat", "Saturday"
GetDayNum = 7
End Select
End Function
And I think the "Mon", "Tue", etc. is where they were coming from on the last question.Weekday(Date()) will return a number, 1 = Sunday, 2 = Monday, etc.
But that's only if you start with a valid date, not "Mon", "Tue", etc.
And I think the "Mon", "Tue", etc. is where they were coming from on the last question.
True - I was going off of the assumption that it was not happening like that. But if it is; then it is much simpler and doesn't need the function. If not, then I THINK we need that custom function.It may be possible to do it all at once, just use:
Format(Date(), "ddd")
Weekday(Date())
Depends on where the info is going though.
True - I was going off of the assumption that it was not happening like that. But if it is; then it is much simpler and doesn't need the function. If not, then I THINK we need that custom function.
Public Function RtnDayNum(pstrDayName As String) As Integer
'*******************************************
'Purpose: Returns day number (1 - 7)
' when provided a complete or partial
' Day name.
'Coded by: raskew
'Input: From debug (immediate) window:
' 1) ? RtnDayNum("Tuesday")
' 1) ? RtnDayNum("Fri")
'Output: 1) 3
' 2) 6
'*******************************************
Dim strHold As String
Dim strDay As String
Dim intDay As Integer
strDay = "SunMonTueWedThuFriSat"
strHold = Left(pstrDayName, 3)
intDay = InStr(strDay, strHold)
RtnDayNum = intDay \ 3 + 1
End Function