I'm facing an issue when trying to add a condition in my sql request
I want add a condition i.e date between DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)
and current date until 23:59:59
.
How can I specify the second part of condition?
thank you.
Asked
Active
Viewed 58 times
0
-
1possible duplicate of [Get row where datetime column = today - SQL server noob](http://stackoverflow.com/questions/2583228/get-row-where-datetime-column-today-sql-server-noob) – Patrick Hofman Sep 21 '15 at 10:47
2 Answers
2
You can do with predicate:
someDate < dateadd(dd, 1, cast(getdate() as date))

Giorgi Nakeuri
- 35,155
- 8
- 47
- 75
0
I usually go with the following:
somedate >= cast(floor(cast getdate() as float) as datetime) and somedate < cast(ceiling(cast getdate() as float) as datetime)

KaraokeStu
- 758
- 7
- 17
-
-
I find his is a safer way, and is backwards compatible - the "date" type didn't use to exist! – KaraokeStu Sep 21 '15 at 13:51