locked
Query Model - What's wrong? RRS feed

  • Question

  • User-848295090 posted
    Model.Where(m => (m.CertificationDate != null && (m.CertificationDate.Value.AddYears(3) > m.CertificationDate.Value.AddYears(3).AddDays(-30)))).ToPagedList(0, 10)
    Friday, February 18, 2011 3:08 PM

Answers

  • User1682618242 posted

    This:

     

    ( m.CertificationDate.Value.AddYears( 3 ) > m.CertificationDate.Value.AddYears( 3 ).AddDays( -30 ) ) )

     is always true. If today is 30.03.2011 in 3 years will be 30.03.2014 which will always be greater than 01.03.2014 (add 3 years and subtracting 30 days).

    You may want to check this:

    ( DateTime.Now > m.CertificationDate.Value.AddYears( 3 ).AddDays( -30 ) ) )

    or something similar

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 18, 2011 11:48 PM

All replies

  • User197322208 posted

    what's the error?

    Friday, February 18, 2011 4:03 PM
  • User1682618242 posted

    This:

     

    ( m.CertificationDate.Value.AddYears( 3 ) > m.CertificationDate.Value.AddYears( 3 ).AddDays( -30 ) ) )

     is always true. If today is 30.03.2011 in 3 years will be 30.03.2014 which will always be greater than 01.03.2014 (add 3 years and subtracting 30 days).

    You may want to check this:

    ( DateTime.Now > m.CertificationDate.Value.AddYears( 3 ).AddDays( -30 ) ) )

    or something similar

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 18, 2011 11:48 PM