Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL 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 September 16th, 2008, 01:01 AM
Authorized User
 
Join Date: Jul 2008
Posts: 18
Thanks: 0
Thanked 2 Times in 2 Posts
Default Error on updating the date field

Please Help me.....

here is my table structure

proj_end_date(field name) date(type) NULL(default)

This my query

UPDATE transprojinfo SET projname = 'Blue Book - Live Nation',
projdescription = 'Scraping the event page of given websites',
proj_initiator = '148',
proj_initiate_date = '2008-09-15',
proj_received_date = '2008-09-15',
proj_status = 'In Progress',
division = 'E Commerce',
proj_end_date = '',
proj_comments = 'asdfasdf' WHERE projid = '15'

This is the error i got.

MySQL said: Documentation
#1292 - Incorrect date value: '' for column 'proj_end_date' at row 1


 
Old September 16th, 2008, 02:58 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Yes? Why are you surprised? A DATE field is *not* a string, even though you are allowed to initialize it with (or compare it to) a specially formatted string.

You can also initialize or compare DATE fields with numbers, so you could have done
     proj_end_date = 0,

But the most sensible thing to do, if you want to purposely *NOT* specifiy a given value, is exactly what you would do with any other field type:
     proj_end_date = NULL,

NULL is a special keyword that is reserved for just this kind of purpose.

Anyway, if you choose to use 0 instead of NULL, then you should probably be consistent and use numbers for your other dates, thus:

UPDATE transprojinfo SET projname = 'Blue Book - Live Nation',
projdescription = 'Scraping the event page of given websites',
proj_initiator = '148',
proj_initiate_date = 20080915,
proj_received_date = 20080915,
proj_status = 'In Progress',
division = 'E Commerce',
proj_end_date = 0,
proj_comments = 'asdfasdf' WHERE projid = '15'

I do *NOT* recommend this. I think NULL is the better choice. But up to you.

p.s.: Why do you use
    WHERE projid = '15'
instead of
    WHERE projid = 15
???

Surely a field named projid is a number field, not a text field. No?
 
Old September 16th, 2008, 11:56 PM
Authorized User
 
Join Date: Jul 2008
Posts: 18
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Thanks old pedant.
yes, you are right.
i have changed it.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Error - Loading date field from flat file to sql carumuga SQL Server 2005 0 August 12th, 2008 09:55 AM
Updating Field in Form cthibault Access 2 January 8th, 2008 03:37 PM
Updating a Date field based on another field arholly Access VBA 6 November 22nd, 2006 11:19 AM
Inserting/updating with empty date field takabyte Classic ASP Databases 3 December 23rd, 2004 02:14 PM
DTS Import ( Date string to Date field) gfowajuh SQL Server 2000 1 September 30th, 2003 06:28 AM





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