saimurali
saimurali

Reputation: 5

how to get only year from date using Distinct from mysql in cakephp

Check the code below:

$this->set('hi', $this->posts->find('all',
array('fields'=>array('DISTINCT year(posts.Post_date)'))));

I am not getting the correct results ... can anyone help me in this please...

my query is (Select distinct year(post_date) from posts);

Thanks

Upvotes: 1

Views: 612

Answers (1)

Ripa Saha
Ripa Saha

Reputation: 2540

replace below

`DISTINCT year(posts.Post_date)`

with below:-

YEAR(DISTINCT posts.Post_date) as year

Upvotes: 3

Related Questions