This is may be silly question. But I am missing logic here. I have to compare dates with date time with hours and minutes (not with seconds).
IF first field time is older then second field execute condition
right now I am doing if (Convert.ToDateTime(newItem["Modified"]) < Convert.ToDateTime(properties.ListItem["Modified"]))
example if("02/12/2015 11:58" < "02/12/2015 12:01")
then execute condition.
If you want to compare only the month, day and year of two dates, following code works for me: SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); sdf. format(date1). equals(sdf.
In JavaScript, we can compare two dates by converting them into numeric values to correspond to their time. First, we can convert the Date into a numeric value by using the getTime() function. By converting the given dates into numeric values we can directly compare them.
You could create new DateTime
objects with mostly the same values, but with seconds set to 0. Example:
DateTime date1WithoutSeconds = new DateTime(dt1.Year, dt1.Month, dt1.Day, dt1.Hour, dt1.Minute, 0);
DateTime date2WithoutSeconds = new DateTime(dt2.Year, dt2.Month, dt2.Day, dt2.Hour, dt2.Minute, 0);
bool b = date1WithoutSeconds < date2WithoutSeconds;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With