Q:

between query for dates not working as i want

i am working on SQL query which take records between two dates "from" To "to" as show in below picture.my query working well but when i change "to" date from 24 to 23 then it does not display the record of 23 date,means last row not display. 

my SQL query is given below:
select  *  from  prescription_master where  (pr.date between @from_date and @to_date) or (pr.date=@to_date)

i want that the record of 23 date also display when i select 23 date from "to" date picker.for this purpose i use "or (pr.date=@to_date)" in above query but it not working.how i can solve this.

A:

You have to handle time part:
select  *  
from  prescription_master 
where  (CAST(pr.date AS DATE) between @from_date and @to_date) 
   or  (CAST(pr.date AS DATE) = @to_date)
   -- this also will made a query non-SARGable

When you provide parameter the date is set to 23-06-2019 00:00:00 and you are comparing it with 23-06-2019 13:08:00

