Last post Jan 26, 2010 05:21 AM by integrasol
Jan 22, 2010 11:48 AM|Aspnab|LINK
So ive been converting an asp website to asp.net. What i did was run the migration wizard in the old VS2003, then when importing it bk into vs2008, i belive it upgraded it agin. I have been plodding along correcting basic erros and have come stuck with this
one. Originallany the site has two input types, one for date and one for time. the new script is below with error im getting. I manged to get the date correct but the time is more tricky. Any suggestions would be appreciated.
Date = FormatdateTime(IIF(IsDBNull(MyRs1.Fields.Item("").Value), Nothing, MyRs1.Fields.Item("").Value), DateFormat.ShortDate)
Time = FormatdateTime(IIF(IsDBNull(MyRs1.Fields.Item("").Value), Nothing, MyRs1.Fields.Item("").Value), DateFormat.ShortTime)
Exception Details: System.InvalidCastException: Conversion from type 'Double' to type 'Date' is not valid.
Line 75: 'TODO Need to correct the format
Line 76: Time= FormatDateTime(IIf(IsDBNull(MyRs1.Fields.Item("").Value), Nothing, MyRs1.Fields.Item("").Value), DateFormat.ShortTime)
Jan 22, 2010 02:51 PM|integrasol|LINK
It looks as if MyRs1.Fields.Item("TMCall").Value returns a value of type Double. What is it stored as in the database?
Jan 25, 2010 12:31 PM|Aspnab|LINK
Thanks for your reply,
So i looked into that and it seems that the DB is holding the times as floats, which according to a work collegue is abit unusal and the main reason why this line is incorrect. We have tried changing the code around but come to a dead end,
Jan 25, 2010 12:44 PM|integrasol|LINK
Was this by any chance because data was imported from Excel at some stage? I've seen this done before, and Excel uses a serial integer to store dates.
Jan 25, 2010 03:03 PM|Aspnab|LINK
I've been asking around and originally is wasnt imported from excel. They used one of there earlier apps(which is over 10 years old) that set it up that way. I have however been given a line of code that they used on there old system that converted it to
work in asp. have been twidling around with it but no joy as yet ......
Jan 26, 2010 05:21 AM|integrasol|LINK
Well, I can make sense of some of this, including the CDate function, but the time format string "hh:bb" makes no sense to me. Is that the actual format, and not "hh:nn" or "hh:mm"? Can you show me an actual value from the float column, please?