How can I refactor this method to look cleaner and free from 2 If statements?If NullableDate.HasValue Then    Dim DayCount As Integer = (DateTime.Now.Date - NullableDate.Value).TotalDays    Dim positive As Boolean = DayCount >= 0    dim TimeLenght as Integer    If positive Then        If DayCount <= 364 Then            TimeLenght = CustomEnum.LessThanOneYear        ElseIf DayCount >= 365 And DayCount <= 729 Then            TimeLenght = CustomEnum.BetweenOneAndTwoYears        ElseIf DayCount >= 728 And DayCount <= 1094 Then            TimeLenght = CustomEnum.BetweenTwoAndThreeYears        Else            TimeLenght = CustomEnum.ThreeYearsPlus        End If    End IfElse    TimeLenght = NothingEnd If
Classifying duration as <1, 1-2, 2-3, or >3 years
datetime;vb.net
Since your requirements are open ended it's difficult to do this without atleast one if statement.  However I think you'll find it much more concise to use Integer division to convert DayCount to the enum value:If positive Then    If Daycount > 1094 Then        TimeLenght = CustomEnum.ThreeYearsPlus    Else        TimeLenght = [Enum].Parse(GetType(CustomEnum), (Daycount \ 365).ToString)    End IfElse    TimeLenght = NothingEnd If