Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Trouble comparing dates with todays date

I'm having an issue when trying to create a custom column that needs to compare an action date with todays date. The cause of the issue has been narrowed down to the below, and I'm not sure why what I've pasted doesn't work?

 

if [Action Date] < DateTime.LocalNow() then "something" else "other"

  • Hi Anonymous,

     

    I guess the data type of [Action Date] is date, while DateTime.LocalNow() returns datetime, which leads to unmatched error.

     

    Please modify your code as below:

    =if [Date] < DateTime.Date(DateTime.LocalNow()) then "something" else "other"

     

    Best regards,

    Yuliana Gu

3 Replies

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Anonymous,

     

    I guess the data type of [Action Date] is date, while DateTime.LocalNow() returns datetime, which leads to unmatched error.

     

    Please modify your code as below:

    =if [Date] < DateTime.Date(DateTime.LocalNow()) then "something" else "other"

     

    Best regards,

    Yuliana Gu

    • Anonymous's avatar
      Anonymous
      Not applicable

      That worked, thank you