TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sai Yang
NA
136
27.7k
[C#] SQL SERVER 2012
May 13 2018 2:32 AM
Hi!
I have this code to select from date to compare to datetimepicker.Text Like:
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.
Reply
Answers (
2
)
How to make undeletable file using C#
How to create custom event in C#