# Timestamp  column query output issue

**URL:** <https://forums.percona.com/t/timestamp-column-query-output-issue/7827>\
**Category:** Percona Server for MySQL 5.7\
**Created:** [July 27, 2020, 11:10am UTC](https://forums.percona.com/t/timestamp-column-query-output-issue/7827 "2020-07-27T11:10:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaibhav\_upadhyay40](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/vaibhav_upadhyay40/32/9_2.png) [@vaibhav\_upadhyay40](https://forums.percona.com/u/vaibhav_upadhyay40)\
**Post date:** [July 27, 2020, 11:10am UTC](https://forums.percona.com/t/timestamp-column-query-output-issue/7827/1 "2020-07-27T11:10:03Z")

</div>

I have a table having timestamp column (c\_created\_time).   
  
While firing&nbsp; a select query using&nbsp;&nbsp;_c\_created\_time_&nbsp;in select and also same column in where clause it shows inaccurate result.  
And  
When i use min function with same where clause as above query it shows different result which is accurate (as expected).  
_ **2nd query output is correct.** _  
&nbsp;  
Note: Minimum value in this table for timestamp column is “2020-06-13 00:00:00” (expected value)  
  
=================  
Table info  
==================  
show create table abc \G\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* 1. row \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*&nbsp; &nbsp; Table: abcCreate Table: CREATE TABLE `abc` (&nbsp; `c_id` bigint(20) NOT NULL AUTO\_INCREMENT,&nbsp; `e_id` bigint(20) NOT NULL,&nbsp; `p_id` varchar(30) NOT NULL,&nbsp; `c_created_time` timestamp NOT NULL DEFAULT CURRENT\_TIMESTAMP,&nbsp; PRIMARY KEY (`c_id`,`c_created_time`),&nbsp; KEY `p_id_idx` (`p_id`)) ENGINE=InnoDB;  
**Query 1 :&nbsp;**  
mysql\> select c\_created\_time from abc where c\_created\_time\>‘1990-01-01 00:00:00’ limit 1;

±--------------------+

| c\_created\_time &nbsp; &nbsp; &nbsp;|

±--------------------+

| 2020-06-17 12:52:46 |

±--------------------+  
mysql\>  
  
**Query 2 :&nbsp;**  
mysql\> &nbsp;select min(c\_created\_time) from abc where c\_created\_time \> ‘1990-01-01 00:00:00’;

±--------------------+

| min(c\_created\_time) |

±--------------------+

| 2020-06-13 00:00:00 |

±--------------------+  
  
Thank you.

---

<div class="post-metadata">

**Author:** ![Kry](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/kry/32/10898_2.png) [@Kry](https://forums.percona.com/u/Kry)\
**Post date:** [October 29, 2020, 8:39am UTC](https://forums.percona.com/t/timestamp-column-query-output-issue/7827/2 "2020-10-29T08:39:38Z")

</div>

Hey.

Your query works correctly because ‘2020-06-17 12:52:46’\> ‘1990-01-01 00:00:00’.

Perhaps for a query without the “MIN” function, you missed “ORDER BY c\_created\_time” for the correct result?

SELECT

c\_created\_time

FROM abc

WHERE c\_created\_time \> ‘1990-01-01 00:00:00’

ORDER BY c\_created\_time

LIMIT 1;
