Les_Salantes
Les_Salantes

Reputation: 315

to_date function issue in PostgreSQL

I have a PostgreSQL table with a column name date_stamp and its data type is "date".
I need to execute the below query and it's not working. Can anyone help? Thank You.
(I am using PHP)

$DS = date('d m Y' ,$data['time_stamp']);       

$query = "SELECT id from ".$this->table_ud." WHERE user_id=43 AND date_stamp=to_date(".$DS.",YYYY MM DD)";

Upvotes: 0

Views: 1060

Answers (1)

xdazz
xdazz

Reputation: 160893

Not necessary to use to_date.

You could just do with:

$DS = date('Y-m-d' ,$data['time_stamp']);       
$query = "SELECT id from ".$this->table_ud." WHERE user_id=43 AND date_stamp='$DS'";

Upvotes: 1

Related Questions