0

I have a colum "datetime", like this: 2012-06-04 15:40:20.

I want to create a query in Doctrine that I get the data of previous time. Less than 2012-06-04 15:40:20. How can I realize that in Doctrine.

Sorry, I just have no clue.

j0k
  • 22,600
  • 28
  • 79
  • 90
craphunter
  • 961
  • 2
  • 13
  • 34

2 Answers2

1

If I understand your question correctly, I believe the syntax is just:

$datetime = // your timestamp

->where('t.somefield < ?', date('Y-m-d H:i:s', strtotime($datetime))
Tom
  • 30,090
  • 27
  • 90
  • 124
0

I am not familiar with Doctrine, but here is standard SQL to do what you want:

select *
from t
where t.datetime in (select max(datetime)
                     from t
                     where datetime < '2012-06-04 15:40:20'
                    )

If Doctrine supports standard SQL syntax, then something like this would work (you might have to input the date/time constant in a different way).

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786