c# - date is getting subtracted while comparing two dates -


i facing problem in code in comparing today's date date in database code. here label10.text containing date database. making reminder app. if database date matches todays date should send reminder email

datetime dt = datetime.parse(label10.text); long t = dt.tofiletime(); datetime date1 = datetime.today; datetime date2 = new datetime(t); //datetime date2 = new datetime(convert.toint64(label10.text)); //datetime date2 = new datetime(2015,9,16); int result = datetime.compare(date1, date2); string relationship; if (result > 0) {     relationship = "is earlier than";     //sendemail();                } else if (result == 0) {     relationship = "is same time as";     sendemail();     //messagebox.show("is same"); }  else {     relationship = "is later than";     sendemail();     //messagebox.show("is later"); } console.writeline("{0} {1} {2}", date1, relationship, date2); 

now problem when run application date2 gets filled 29.09.15 whereas label 10 shows 30.09.15. not getting why happening have noticed "dt" gets filled 30.09.15 12:00:00 "date 2" 29.09.15 06:30:00 pm, don't have other record in db have reminder date set 29.09.15

have checked if issue has time difference between local time , utc time? database time utc time, while code behind uses localtime. convert times either local or universal.

// converting local time date1.tolocaltime(); // converting utc time date1.touniversaltime(); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -