select tb_payment.BillID,tb_payment.ContractID,tb_payment.Customername,cast(replace(tb_payment.Amountpertimer,',','')as float)
/ cast(replace(tb_exchange.Exchange,',','')as float) as Amountpertimer,tb_payment.Paystyle,tb_payment.Currency,tb_payment.Termpay,
tb_payment.Latedays,cast(replace(tb_payment.Fineamount,',','')as float)/CAST(REPLACE(tb_exchange.Exchange,',','')as float)as
Fineamount,tb_payment.Datepay from tb_payment, tb_exchange where tb_payment.Currency='Baht' and tb_exchange.Currency='Baht' and
CAST(FLOOR(CAST(tb_payment.Datepay as float))as datetime) BETWEEN '"+dateTimepicker1.Text+"' AND '"+dateTimepicker2.Text+"' order by BillID asc
the error is:
#.If in my table tb_payment has datepay between 01/05/2018 to 13/05/2018
1. If I select between 01/05/2018 or date after 01, and 13/05/2018 is working correctly but if I select between 01/05/2018 and 14 or 15 or ...##/05/2018 this making error :
Msg 242, Level 16, State 3, Line 2
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Why this return error and where the error is?
the Sql server 2012 table tb_payment.Datepay is datetime datetype.
Advance Thanks.