I am trying to build a date using DateSerial but some of the numbers/Variables it's not liking. Day(WeekEndDay - (6 - DayNumber)))
I get one of two errors.
1. can't convert integer to date.
2. Conversion form type double to date is invalid.
so How can I convert or cast this?
I also tried changing that line to: but get squgilly under it saying "can't convert integer to date."
DougP
I get one of two errors.
1. can't convert integer to date.
2. Conversion form type double to date is invalid.
so How can I convert or cast this?
Code:
Public Function WhichDate(ByVal DayNumber, ByVal WeekEndDate)
' figure out which date by the day number of the week.
Dim Today, TheDay As Integer
Dim WeekEndDay As Integer = Day(WeekEndDate)
'Dim WeekEndMonth = Month(WeekEndDate)
'Dim WeekEndYear = Year(WeekEndDate)
Dim WhichDate1 As Date
Try
If WeekEndDate <> DetermineWeekEndingDate("justdate") Then
WhichDate1 = DateSerial(Year(WeekEndDate), Month(WeekEndDate),[COLOR=red] Day(WeekEndDay - (6 - DayNumber)))[/color]
Else
Today = Now.DayOfWeek
TheDay = Today - DayNumber
WhichDate1 = DateSerial(Year(Now), Month(Now), Day(Now) - TheDay)
End If
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Information, "Error")
End Try
WhichDate = WhichDate1
End Function
I also tried changing that line to: but get squgilly under it saying "can't convert integer to date."
Code:
Dim NewDay As Integer = WeekEndDay - (6 - DayNumber)
WhichDate1 = DateSerial(Year(WeekEndDate), Month(WeekEndDate), Day(NewDay))
DougP