Last post Apr 01, 2019 01:21 PM by limno
Mar 30, 2019 07:58 AM|Gopi.MCA|LINK
My Field Is Date time = Bill_Date_Time
Data in my table will be like this format
My query is select * from Table1 where Bill_Date Between @FD and @TD
If i pass this it fetch from data perfect but ToData is not showing in pass date why?
it showing only Todata one day before not exact pass datetime.
Mar 30, 2019 09:09 AM|yrb.yogi|LINK
Assuming you are passing the from & to date only (Not the Date & Time), so you will need to use the below query to get the result.
select * from Table1 where CAST(Bill_Date AS DATE) Between CAST(@FD AS DATE) and CAST(@TD AS DATE)
Mar 30, 2019 11:24 AM|PatriceSc|LINK
Likely because @TD is not correct ? For example if I want to select data for today I'm using :
WHERE Bill>='20190330' AND Bill<'20190331' -- ie from today until the beginning of the NEXT day
Mar 31, 2019 03:17 PM|wmec|LINK
select * from Table1 where Bill_Date Between CONVERT(datetime,@FD,112) and CONVERT(datetime,@TD,112)
and @FD and @TD should be varchar data type, with the values (as an example) like
Apr 01, 2019 01:21 PM|limno|LINK
Datetime has time portion. A date will be converted to the beginning of day in datetime form.
I assume you pass a date as your parameter then, you need to add one day to it and use this syntax:
select [ yourcolumn list] from Table1
where Bill_Date >=@FD and Bill_Date < (dateadd(day,1,@TD)