DateTime.Now in Where Clause
Posted: Tue 11 May 2010 14:50
If I want to filter results by DateTime.Now it doesn't work.
Like this:
This is the SQL shown in debug mode... if I test directly in Oracle, it works.
Directly in Oracle it returns only rows that "PUBLICACAO" was in the past hours, but in EntityFramework, it returns rows in the future too.
Any idea?
Ps. In the future I mean in the next hours, but not in the next days.
[UPDATE]
If I define a variable first, it works. Ex.:
Like this:
Code: Select all
var capa = from c in db.CapaAgendamentos where c.Publicacao <= DateTime.Now select c;
Code: Select all
SELECT * FROM SITE.TD_CAPA_AGENDAMENTO WHERE PUBLICACAO <= (CURRENT_DATE)
Any idea?
Ps. In the future I mean in the next hours, but not in the next days.
[UPDATE]
If I define a variable first, it works. Ex.:
Code: Select all
DateTime now = DateTime.Now;
var capa = from c in db.CapaAgendamentos where c.Publicacao <= now select c;