Saturday, August 25, 2012

Re: I want to find records during last 24 hours

Yasir,

I'm getting a bit bored of these replies that have no content and just a link (to a 1 sentance "answer"). 
If it's not obvious the group is not public so there is no SEO value in doing that.

Metz,

why would you use between for such a query?

    $this->User->find('all', array(
        'conditions' => array(
            'last_seen >' => date('Y-m-d H:i:s', strtotime('-1 day'))
        )
    ));

Is a simpler query (and it's just an example - you can build the date condition any way you like) - unless you have data such that it's possible to be seen in the future (?) you don't need between.

AD

On Friday, 24 August 2012 18:20:40 UTC+2, Arafat wrote:
I think this will help you

http://arafats.info/cakephp-date-comparison-or-cakephp-date-bewteen-on-database-data/

Thanks
Arafat

On Tue, Aug 21, 2012 at 11:54 PM, MetZ <met...@gmail.com> wrote:

How can I find the Users that are "last_seen" the last 24hours?

[User][last_seen] => 2012-08-18 08:10:31

last_seen is updated each time a logged in user browse the website with current timestamp

This is what I have tried this far:

$users = $this->User->find('all',array('conditions'=>array('User.last_seen >' =>'BETWEEN NOW() AND NOW()- INTERVAL 24 HOURS'),'recursive'=>-2));

But my array is coming back empty.

Suggestions??

As always!! You are awesome! Thanks for your time!

-Tom

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake...@googlegroups.com.
To unsubscribe from this group, send email to cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 



--
Thanks & Regards.
-----------------------------------------------------------------------------------------------------------------------------
Yasir Arafat (Hasib)
Deputy Project Manager, Software Solutions
Grameen Solutions
Contact Information:
Cell : +8801816 536 901, +880197 333 2 888
Web: http://arafats.info

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: