Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 458347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:39:45+00:00 2026-05-12T22:39:45+00:00

I have a bill_date field that I want to be blank (NULL) until it’s

  • 0

I have a “bill_date” field that I want to be blank (NULL) until it’s been billed, at which point the date will be entered.

I see that MySQL does not like NULL values in datetime fields. Do any of you have a simple way to handle this, or am I forced to use the min date as a “NULL equivalent” and then check for that date?

Thanks.

EDITED TO ADD:

Ok I do see that MySQL will accept the NULL value, but it won’t accept it as a database update if I’m updating the record using PHP.

The variable name is $bill_date but it won’t leave the variable as NULL if I update a record without sending a value to $bill_date — I get this error:

Database query failed: Incorrect datetime value: '' for column 'bill_date' at row 1

I assume I need to actually send the word NULL, or leave it out of the update query altogether, to avoid this error? Am I right? Thanks!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:39:45+00:00Added an answer on May 12, 2026 at 10:39 pm

    MySQL does allow NULL values for datetime fields. I just tested it:

    mysql> create table datetimetest (testcolumn datetime null default null);
    Query OK, 0 rows affected (0.10 sec)
    
    mysql> insert into datetimetest (testcolumn) values (null);
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select * from datetimetest;
    +------------+
    | testcolumn |
    +------------+
    | NULL       | 
    +------------+
    1 row in set (0.00 sec)
    

    I’m using this version:

    mysql> select version();
    +-----------+
    | version() |
    +-----------+
    | 5.0.45    | 
    +-----------+
    1 row in set (0.03 sec)
    

    Speaking of inserting NULL values through PHP code, given you are using prepared statements (as you definitely should), there is no problem with inserting NULL values. Just bind your variable the usual way, and all PHP variables that contain null values will be stored as NULL in MySQL.

    Just make sure that your PHP variable indeed contains NULL and not an empty string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following models: class Bill(models.Model): date = models.DateTimeField(_(Date of bill),null=True,blank=True) class Item(models.Model):
I am pretty much sure that this question have been asked and answered several
using ASP.NET MVC, I have a Model, to which I'm attaching attributes so that
I have the following SQL that returns the max BILL_DATE based on some criteria.
it is possible that similar questions have been asked earlier, but I can't find
I have made a phone bill system takes input of phone number called, date
Lets assume i have a bill number that has 12 numbers: 823 45678912 My
I have a txt file that include information as follow: Jack Jim Bill's Father
have been playing with Cubepoints (wordpress plugin) and have installed the ranks module but
I have a model with several date attributes. I'd like to be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.