Forum Discussion

kasife's avatar
kasife
Icon for Helper V rankHelper V
3 years ago

Compare Dates in M

Hi Guys,

 

How to compare a specific date column with today's date?

For exemplo: 

if 26/10/2022 (createdDate Collumn) < 26/04/2022 then null

 

5 Replies

  • pls try this

     

    if Value.Is([date], type date) and [date] >= Date.From( DateTime.LocalNow())  then "ok" else null

     

  • Hi kasife,

     

    For this comparision you can use the following code:

    if [Date] < DateTime.LocalNow() then null else "ok"

    The OK can be whatever you want since  using and if statement you always need the result for true and for false.

     

    • kasife's avatar
      kasife
      Icon for Helper V rankHelper V

      MFelix 

      I did it that way, but errors appear and the message "We were unable to convert the null value to the logical type"

       

       

      • MFelix's avatar
        MFelix
        Icon for Super User rankSuper User

        Try the following code

         

        try if [Date] < DateTime.LocalNow() then null else "ok" otherwise null