Setting a datetime

1. Member
Join Date
Dec 1969
Posts
38

## Setting a datetime

I need to set a DateTime, both the date and time, but haven&#039;t found the right combination. It doesn&#039;t like <BR><BR>&#039;2001/02/03 18:06:02.000&#039;<BR><BR>One bit, complaining that it can&#039;t convert data type VARCHAR to Numeric.

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## VARCHAR to NUMERIC???

Why would it be trying to do that???<BR><BR>If the field is DateTime it should be trying to convert VARCHAR to DATETIME.<BR><BR>Double check the schema? Maybe you inadvertently got the field type wrong?<BR><BR>If not, show the entire query. Please, *NOT* ASP code.<BR><BR>Response.Write the SQL so we can see what you are actually passing to the DB.<BR><BR>

3. Member
Join Date
Dec 1969
Posts
38

## RE: VARCHAR to NUMERIC???

BINGO! I wonder why it&#039;s NUMERIC(14,2).

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Want to know why dates were working?

You did<BR><BR>INSERT ... thatFunnyField = &#039;10/5/2001&#039; ...<BR><BR>right?<BR><BR>Let&#039;s see...10/5 is 10 divided by 5, so that&#039;s 2. Then<BR>2/2001 is 0.00099950025. And storing *that* valud in a NUMERIC(14,2) field meant rounding it to two decimal places, so...<BR><BR>Congratulations, you found a long way of storing zero in a field.<BR><BR>&#060;grin /&#062;<BR><BR>[ In other words, the /&#039;s in the dates were being interpreted as division signs, since it needed to do a VARCHAR to NUMERIC conversion. ]<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•