469,307 Members | 2,466 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,307 developers. It's quick & easy.

Inserting date issue

Iíve finally made the jump from Access to SQL Express but Iím having some difficulty inserting a date using an asp/vbscript page.

Iíve trawled the web and persisted with trial and error and basically Iím down to 2 outcomes.

The firstÖ

Formatting the date before insert, all combination of day month and year using / or - as a separator. The insert works but shows in the table as either 01/01/1900 or some other crazy combination.

The secondÖ

Formatting the date as yyyymmdd as recommended up and down the web produces this error

Microsoft OLE DB Provider for ODBC Drivers (0x80040E57)
[Microsoft][SQL Native Client][SQL Server]Arithmetic overflow error converting expression to data type datetime.

Iím very new to SQL so I could be wrong but Iím starting to think this is a SQL configuration issue.

The SQL column is set to datetime
The user language (user defined in the connection string) is set to British English although Iíve tried plain English too.

Any ideas welcome.
Aug 16 '07 #1
3 1077
Have you tried this?

Expand|Select|Wrap|Line Numbers
  1. Convert(datetime,'YYYY-MM-DD')
Aug 16 '07 #2
Can that be used in an asp/vbscript page?

Sorry I should have made it clear I'm doing this via an asp page
Aug 16 '07 #3
Sure, just put that into your SQL string with the rest of the SQL statement.

So if I had an ASP variable called strVar1 containing a date string of '2007-08-16' to insert that into sql I would do the following.
Expand|Select|Wrap|Line Numbers
  1. SQL = "Insert into DateField Select convert(datetime," & strVar1 & ")"
Aug 16 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by J. Muenchbourg | last post: by
6 posts views Thread by fniles | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.