Tuesday, January 18, 2022

[FIXED] Select the rows with custom date format in MySQLi

Issue

I want to select the rows with custom date format in MySQLi. Here is the image of my database.

enter image description here

if the `publish_date` is like 1540182298,1540182469,1540183281

$sql="SELECT * FROM new_enquery WHERE date_format(publish_date, '%Y')='2018'";


Solution

Seems unix timestamp so you could try using FROM_UNIXTIME

SELECT * FROM new_enquery WHERE FROM_UNIXTIME(publish_date, '%Y')= '2018'


Answered By - ScaisEdge

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.