-
DatePart error
I hav this field 'Time' in my database (of the type date/time), and I use an System.data.oledb.OLEDBDataReader to read this field.
When simply response.write(DR.Item('Time')) to the browser i get this:
12-05-2002 20:05:00
However, if I use DatePart(DR.Item("Time"),"d") i get this error:
System.InvalidCastException: Argument 'DateValue' cannot be converted to type 'Date'.
Any suggestions?
-
you're probably better off returning a date from a sql server stored procedure that excludes the time:-
select convert(datetime, datepart(mm, datefield) + '/' + datepart(dd, datefield) + '/' + datepart(yy, datefield)) as date
Think that will work.
-
Does that work in OLEDB also? I'm not using MS SQL server...
-
It's probably a different function in access. If you search under date functions you should find it.