Invalid character value for cast specification

General discussion forum about all databases other than SqlBase.

Invalid character value for cast specification

Post by sliddle » 04 Feb 2010, 11:51


A client's pc produces the error 'Invalid character value for cast specification ( see attached ) when saving changes to the database

When the client makes a change to the 'Personal Details' screen e.g address and clicks the 'Save' button it displays the 'Update Dated Record' screen which populates the 'Valid from date:' with 2-Feb-2010. When the client clicks the 'Apply' button which Inserts the changes to the database ( sql server 2000 ) it gives the above error. The problem is caused by the 'Valid From date' missing the leading zero from day i.e '2-Feb-2010' instead of '02-Feb-2010'.

When I try to replicate the probem on my pc then no combination of changing Regional Settings date formats ( i.e short date/long date format e.g d mm yyyy ) will force my pc to display the date similar to the clients pc .

I cant understand why the clients pc is displaying the date as 2-Feb-2010 ( i.e with the leading zero removed ) which seems to be causing the problem

Anyone got any suggestions ?
You do not have the required permissions to view the files attached to this post.

Jeff Luther

Re: Invalid character value for cast specification

Post by Jeff Luther » 08 Feb 2010, 18:39

Assuming the field is of type DateTime, setting its fomat to this: dd-MMM-yyyy
should result in a display like this: 08-Feb-2010

Try that, if that missing leading zero is really the problem.

If that date field is really a string, then you'll need to do a little parsing to prepend a '0' so the value is compatible with what MS SS expects. Otherwise, you might need to write and test with a small app using CAST to get MS SS to accept the data value. Here's further info: ... 80%29.aspx

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 3 guests