c# - dateTimePicker1.Value < dateTimePicker2.Value = true when values are identical on runtime -


i have datetimepicker1 , datetimepicker2 controls loading on form1. both have same date , time on load.

        datetimepicker1.format = datetimepickerformat.custom;         datetimepicker1.customformat = "yyyy-mm-dd hh:mm:ss";         datetimepicker2.format = datetimepickerformat.custom;         datetimepicker2.customformat = "yyyy-mm-dd hh:mm:ss"  

when check if have different values using

if (datetimepicker1.value < datetimepicker2.value) {     console.writeline(datetimepicker1.value + " earlier " + datetimepicker2.value); } 

the statement returns true , writes console. not expect. expect return false.

if increase each control's value 1 second, causing them still match, statement returns false expected , nothing written console.

why less evaluation return true on load when both values identical?

do not know how loading values. but, depending on precision looking (eg. in hours, minutes or second) can subtract 2 values , compare. example: if need precision in seconds can similar below:

        datetimepicker1.value = datetime.now;         datetimepicker2.value = datetime.now.addmilliseconds(999);         var timespan1 = datetimepicker1.value - datetimepicker2.value;         if (math.abs(timespan1.totalseconds) > 1) {             messagebox.show(datetimepicker1.value + " not same " + datetimepicker2.value);         } else {             messagebox.show(datetimepicker1.value + " same " + datetimepicker2.value);         } 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -