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

  • SEARCH
  • Home
  • 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 9168351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:36:23+00:00 2026-06-17T15:36:23+00:00

I have the table below: +————-+——————+——+—–+——————-+—————-+ | Field | Type | Null | Key

  • 0

I have the table below:

+-------------+------------------+------+-----+-------------------+----------------+
| Field       | Type             | Null | Key | Default           | Extra          |
+-------------+------------------+------+-----+-------------------+----------------+
| category_id | int(11) unsigned | NO   | PRI | NULL              | auto_increment |
| title       | varchar(64)      | NO   |     | NULL              |                |
| description | text             | NO   |     | NULL              |                |
| created_on  | timestamp        | NO   |     | CURRENT_TIMESTAMP |                |
| updated_on  | timestamp        | YES  |     | NULL              |                |
+-------------+------------------+------+-----+-------------------+----------------+

I needed to delete some records according to the date created and executed a set of queries:

mysql> select created_on from categories limit 10;
+---------------------+
| created_on          |
+---------------------+
| 2013-01-14 09:26:21 |
| 2012-08-15 11:18:38 |
| 2012-09-06 06:44:46 |
| 2012-09-06 23:27:14 |

then

mysql> select date('2013-01-14 09:26:21');
+-----------------------------+
| date('2013-01-14 09:26:21') |
+-----------------------------+
| 2013-01-14                  |
+-----------------------------+

and finally I got:

mysql> select DATE('created_on') from categories limit 10;
+--------------------+
| DATE('created_on') |
+--------------------+
| NULL               |
| NULL               |
| NULL               |
| NULL               |

As you can see the date wasn’t converted correctly. In about 10 minutes is worked ok:

mysql> select date(created_on) from categories limit 10;
+------------------+
| date(created_on) |
+------------------+
| 2013-01-14       |
| 2012-08-15       |
| 2012-09-06       |
| 2012-09-06       |

I’m sure that the data were intact while I was running the queries.

So my question:

Can anybody explain why date function showed different results on the same input?

  • 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-06-17T15:36:24+00:00Added an answer on June 17, 2026 at 3:36 pm

    You have to use::

    select DATE(created_on) from categories limit 10;
    

    By using the inverted comma, you are asking the database to treat 'created_on' as parameter, and since it cannot be converted to date type, you are getting null

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

Sidebar

Related Questions

I have a table as below ID Date 1 Null 1 Null 1 Null
I have table as shown below. In order to workaround one default now column
I have 2 table with below structure : Table 1 (Tb1) : MasId Int,
I have below table structure ID int xmlData xml I want data in the
I have table as below create table myTable (id int, col1 varchar(20), col2 varchar(20),
I have table like below : <table> <thead> <th>Product Type</th> <th>Quantity</th> <th>Unit</th> <th>Total</th> </thead>
I have table as below personalInfo CREATE TABLE personalInfo(userid BIGINT AUTO_INCREMENT PRIMARY KEY) patentInfo
Lets say I have table as below. create table t1 (id INT, tempData varchar(25));
I have below table in my MS SQL 2008 MyTable ---------------------- ID int (identity),
i have the table below <tr id=group_1>...</tr> <tr id=el>...</tr> <tr id=el>...<tr> <tr id=group_2></tr> <tr

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.