I know when you see topic you said this question asked before but mine is different. I have a db and a table Date1. Date1 is varchar and i keep date in dd.mm.yyyy format(104). in my form i have two datetimepicker
: date1
and date2
. when click submit button i cant get information between two dates. it gives conversion error. I wrote this sql command. can you solve problem?
SqlDataAdapter adtr = new SqlDataAdapter("select * from EvrakArsiv where
CONVERT(DATETIME,KAYITTARIHI,104)>='"+tbIlkTarih.Value.ToString("dd.mm.yyyy")+"' and
CONVERT(DATETIME,KAYITTARIHI,104)<='"+tbSonTarih.Value.ToString("dd.mm.yyyy")+"'",
connection);
In .NET the mm
in a DateTime
format string means minutes , not months. You want MM
, with capital M. Otherwise you get the minutes part of your System.DateTime
which is likely 00
(whole hour).
So change:
tbIlkTarih.Value.ToString("dd.mm.yyyy")
into:
tbIlkTarih.Value.ToString("dd.MM.yyyy")
and similarly for the other control.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.