Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2007, 01:21 PM
Authorized User
 
Join Date: Feb 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Microsoft OLE DB Provider for ODBC Drivers (0x8004

Hi , I'm trying to have a date format mm-dd-yy but it gives me this error :

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E31)
Incorrect datetime value: '4-24-2007' for column 'modDate' at row 1
/save_inc.asp, line 20

Line 20 : '"&DatePart("M", Date)&"-"&DatePart("D", Date)&"-"&DatePart("YYYY", Date)&"'

earlier it was working fine with :'"&DatePart("YYYY", Date)&"-"&DatePart("M", Date)&"-"&DatePart("D", Date)&"'

Plz advise.


 
Old April 24th, 2007, 01:48 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I am missing something here; what database are you using? This is related to the value you are trying to insert, not necessarily the code you are using to generate the value.

(To be honest, I am not sure what is wrong because if i do: INSERT INTO table(modDate)Values('4-24-2007') SQL server accepts it just fine.)

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old April 24th, 2007, 01:54 PM
Authorized User
 
Join Date: Feb 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm using MySQL database.And my datatype for ColumName modDate is DATETIME .

 
Old April 24th, 2007, 02:03 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Hmm. Havent used MySQL in awhile, though I know its implementation of the SQL Standard differs from SQL Server. Anywho. Open up Query Browser and run a manual insert:

INSERT INTO table(modDate)Values('4-24-2007')
and
INSERT INTO table(modDate)Values('04-24-2007')

Which one passes which one fails?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old April 24th, 2007, 02:23 PM
Authorized User
 
Join Date: Feb 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I need to make changes in this sql statement actually


Code:
sql = "insert into projects (modDate, modName, Scenario, projComments) values ('"&DatePart("M", Date)&"-"&DatePart("D", Date)&"-"&DatePart("YYYY", Date)&"','"&modName&"','"&projName&"','"&projComments&"')"
db_conn.execute(sql)
 
Old April 25th, 2007, 10:27 AM
Authorized User
 
Join Date: Feb 2007
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I figured out how to put YYYY-M-D format ..changed the datatype from datetime to date and then used :

sql = "insert into projects (modDate, modName, Scenario, projComments) values ('"&DatePart("YYYY", Date)&"-"&DatePart("M", Date)&"-"&DatePart("D", Date)&"','"&modName&"','"&projName&"','"&projComme nts&"')"
    db_conn.execute(sql)

But I prefer it in mm-dd-yy format , how can i do that ??!

 
Old April 25th, 2007, 10:30 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The last time I worked with MySQL it was overly picky about how dates were placed into the system. I always ended up having to convert the date upon SELECT to get the correct format that I wanted. Your best bet would be to head over to the MySQL site and check out their help section; there is a whole page dedicated to DateTime.
hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft OLE DB Provider for ODBC Drivers phantom3008 Classic ASP Basics 6 March 15th, 2007 09:39 AM
Microsoft OLE DB Provider for ODBC Drivers error ' rajiv_software Classic ASP Basics 6 April 28th, 2005 12:52 AM
Microsoft OLE DB Provider for ODBC Drivers surendran Classic ASP Databases 4 October 27th, 2003 10:23 AM
OLE DB Provider for ODBC Drivers error '80004005' Routhg Access ASP 2 June 11th, 2003 07:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.