Hello all,
Im pulling a date out of SQL Server that is 04141991 format and i need to change it to 19910414. I'm pretty new to ASP and I inherited this app from the previous IT person.
strSql= " Select * from enrolldep where enrollid = '" & strEnrollID & "'"
Set rst2 = dbConn.execute(strSql )
reccount = 15
do while not rst2.EOF
reccount = reccount + 1
strDepLastName = trim(rst2.Fields("DepLastName"))
strDepFirstName = trim(rst2.Fields("DepFirstName"))
strDepSSN = trim(rst2.Fields("DepSSN"))
strDepMI = trim(rst2.Fields("DepMiddleInitial"))
strDepRelation = trim(rst2.Fields("DepRelation"))
strDepGender = trim(rst2.Fields("DepGender"))
strDepDOB = trim(rst2.Fields("DepDOB"))
straddordel = trim(rst2.Fields("addordel"))
'need to convert the date to yyyymmdd for the dep dob
if Len(trim(strDepDOB)) > 1 then
strYear = Year(strDepDOB)
strMonth = Month(strDepDOB)
if len(strMonth) = 1 then
strMonth = "0" & strMonth
end if
strDay = day(strEmpDOB)
if len(strDay) = 1 then
strDay = "0" & strDay
end if
strFormatedDepDOB = strYear & strMonth & strDay
End IF
Then we have the response.write stuff to display the variables on the webpage and the loop.
The error shows up for this line of the conversion: strYear = Year(strDepDOB)
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "04141991"]'
/app/companywide/onlineenrollment/PendEmp.asp, line 1321
The odd thing is, I have this exact same code earlier in the page to format another date and it works perfectly.
Any help would be much appreciated!
Mel
Im pulling a date out of SQL Server that is 04141991 format and i need to change it to 19910414. I'm pretty new to ASP and I inherited this app from the previous IT person.
strSql= " Select * from enrolldep where enrollid = '" & strEnrollID & "'"
Set rst2 = dbConn.execute(strSql )
reccount = 15
do while not rst2.EOF
reccount = reccount + 1
strDepLastName = trim(rst2.Fields("DepLastName"))
strDepFirstName = trim(rst2.Fields("DepFirstName"))
strDepSSN = trim(rst2.Fields("DepSSN"))
strDepMI = trim(rst2.Fields("DepMiddleInitial"))
strDepRelation = trim(rst2.Fields("DepRelation"))
strDepGender = trim(rst2.Fields("DepGender"))
strDepDOB = trim(rst2.Fields("DepDOB"))
straddordel = trim(rst2.Fields("addordel"))
'need to convert the date to yyyymmdd for the dep dob
if Len(trim(strDepDOB)) > 1 then
strYear = Year(strDepDOB)
strMonth = Month(strDepDOB)
if len(strMonth) = 1 then
strMonth = "0" & strMonth
end if
strDay = day(strEmpDOB)
if len(strDay) = 1 then
strDay = "0" & strDay
end if
strFormatedDepDOB = strYear & strMonth & strDay
End IF
Then we have the response.write stuff to display the variables on the webpage and the loop.
The error shows up for this line of the conversion: strYear = Year(strDepDOB)
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "04141991"]'
/app/companywide/onlineenrollment/PendEmp.asp, line 1321
The odd thing is, I have this exact same code earlier in the page to format another date and it works perfectly.
Any help would be much appreciated!
Mel