0

I'm trying to display a recordset pulled from SQL Server using classic asp. I can display the regular data fine, however there is one field which is DateTime datatype in the database.

How do I Response.Write the date?

I've tried this

<%=objRS(FormatDateTime("startdate",vbshorttime))%>

But it throws the error:

Description: Type mismatch: 'FormatDateTime'

What am I missing?

3
  • The recordset field objRS("startdate") if you want to use FormatDateTime() you can do something like <%= FormatDateTime(objRS("startdate"), vbShortTime) %>.
    – user692942
    Dec 7, 2019 at 22:40
  • No, still geting the same error. Script error detected at line 79. Source line: Response.Write FormatDateTime(objRS("startdate"), vbShortTime) Description: Type mismatch: 'FormatDateTime'
    – user2601252
    Dec 7, 2019 at 23:22
  • In which case the field isn’t a Date. Try CDate(objRS("startdate")) to see if it is a value that can be converted to a date.
    – user692942
    Dec 8, 2019 at 10:04

1 Answer 1

0

Silly error that I missed. The data values were null so I added a condition to check for null values.