Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Build a valid date with DATE function (dd.mm.yy)

Dear all,


I have some issues with building a valid date from this source:

I have tried:

DATO = DATE(TRLO[TRL_DAG], TRLO[TRL_DMND], TRLO[TRL_AAR])
 
I guess the formula fails because of the two character year. Any suggestions?

Best regards
Kenneth Pedersen
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    30 in the TRLO[TRL_DAG] stands for 2030, right?

    Adding two digits to 2000 turns it into a four-digit year.

     

    DATO = DATE(2000+TRLO[TRL_DAG], TRLO[TRL_DMND], TRLO[TRL_AAR])

     

    Then you can change the format you want.

     

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

5 Replies

  • Anonymous , Not very clear.

    In the date function DATE you should give Year, month , date

     

    Ate you giving those values ?

  • Anonymous Try this DAX Column:

    Date Column = FORMAT(DATE(DateTable[Year],DateTable[Month],DateTable[Day]),"dd.mm.yy")
     
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much.

      I tried: 

      DATO = FORMAT(DATE(TRLO[TRL_DAAR], TRLO[TRL_DMND], TRLO[TRL_DAG]), "yy.mm.dd")

      and this one too:
       
      DATO = FORMAT(DATE(TRLO[TRL_DAAR], TRLO[TRL_DMND], TRLO[TRL_DAG]), "dd.mm.yy")

      I still get error message (in english like this): One argument in function DATE has wrong data type, or the result is too big or too small.

      Best regards
      Kenneth Pedersen
      • Tahreem24's avatar
        Tahreem24
        Super User

        Anonymous Make sure all Year, Month, and Day columns are of type interer or whole number. They should not be a text column.

         

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    30 in the TRLO[TRL_DAG] stands for 2030, right?

    Adding two digits to 2000 turns it into a four-digit year.

     

    DATO = DATE(2000+TRLO[TRL_DAG], TRLO[TRL_DMND], TRLO[TRL_AAR])

     

    Then you can change the format you want.

     

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.