# DayRound Rounding Values:No difference between “Preceding” and “Following”?

On Mathematica 10.0.1 both

DayRound[{1980, 2, 29}, "EndOfMonth", "Preceding"]


and

DayRound[{1980, 2, 29}, "EndOfMonth", "Following"]


produce

DateObject[List[1980,2,29],Rule[CalendarType,"Gregorian"]]


Is that correct? I would expect that the first one would produce the January 31 and the later one to produce March 31.

This is documented behavior. From the docs on DayRound >> Details and Options:

In DayRound[date, daytype, rounding]

If date is of daytype, DayRound has no effect.

So, since {1980, 2, 29} an "EndOfMonth" day, its "rounded" form is itself. And

DayRound[{1980, 2, 28}, "EndOfMonth","Preceding"]


return DateObject[{1980, 1, 31}, CalendarType -> "Gregorian"] as expected. However, you need

DayRound[{1980, 3, 1}, "EndOfMonth","Following"]


to get DateObject[{1980, 3, 31}, CalendarType -> "Gregorian"].

• thanks. Yet I still struggle to understand the logic of "Preceding" and "Following" having no effect. – iav Nov 9 '14 at 18:29
• @iav, i agree it does feel puzzling. Perhaps it helps to try to think of "Preceding" and "Following" in the weak inequality (LessEqual and GreaterEqual) sense. – kglr Nov 9 '14 at 18:37