Reputation: 243
I have a birthday date column of employees. I want to find out the employees whose birthday on this date.
I am passing a date to a query h to get employ whose birthday on this date. But the problem is that date is given in DateTime formate and table birthday column also in DateTime formate.
eg, 2017-04-25 09:00:00
I want results on basic of date only not on their time. For example:
In table date is given in birthday column
2017-04-25 09:00:00
2017-04-25 05:00:00
I am passing date 2017-04-25 09:00:00
in JPA query then both date should return. The result should be on the basis of date only.
Upvotes: 0
Views: 181
Reputation: 26
declare @inputdate datetime
select * from Emp_table where Cast(birthdaycol as date)= cast(@inputdate as date)
Upvotes: 1
Reputation: 570
You may try like below query:
select * from your table where date(yourDateColumn)='2017-04-25'
Upvotes: 1
Reputation: 50163
Use cast()
or convert()
where cast(birthday as date) = '2017-04-25'
For your parameter you can express this as
where cast(birthday as date) = cast(@parameter as date)
Upvotes: 1