Way to have MySQL Date field remain empty, no 0000-00-00

I am attempting to have a date field remain empty when the form is processed and the data is inserted into the MySQL database.  I would like the date field to remain empty, instead of populating with 0000-00-00.

Is there a way to do this without changing the datatype of the field?
tru504187211Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roger BaklundCommented:
No, I don't think so. The 0000-00-00 is the internal "empty" for a NOT NULL date column. But you don't have to output this, you can change it in the select:
SELECT ... if(dateCol='0000-00-00','',dateCol) as dateCol, ... 
FROM ...

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tru504187211Author Commented:
cxr:  Thanks for the reply.  I understand what you mean, partially about the if (datecol='0000-00-00'), but am unsure what could be done about it.  How could I go about doing...

If(datecol='0000-00-00')
display 'Today's Date instead'

...or somehow display today's date...
0
Roger BaklundCommented:
That would be like this:
SELECT ... if(dateCol='0000-00-00',CURDATE(),dateCol) as dateCol, ... 
FROM ...

Open in new window

0
Roger BaklundCommented:
The IF() function takes three parameters:  IF(<expression>,<true-output>,<false-output>)
0
tru504187211Author Commented:
Got it to work!  Thanks for the assistance!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.