Compare two dates in c# from Mysql -
i have column in database named tblreburial , field reburialdate. type varchar , format of date (yyyy/dd/mm).in c# have query:
string query = "select date_format(reburialdate,'%y/%d/%m') reburialdate tblreburial";
in while statement:
while (myreader.read()) { string date = (myreader["reburialdate"].tostring()) if(date == datetime.now.tostring("yyyy/dd/mm")){ //some statements } }
i tried many ways string not recognized valid datetime.
you can convert datareader
datetime , compare datetime.today
var date = datetime.parse(myreader["reburialdate"]) if(date.date == datetime.today) { //some statements }
you can optionally pass format information datetime.parse
. here msdn documentation.
Comments
Post a Comment