Forum Discussion

sdnd2000's avatar
sdnd2000
Copper Contributor
Jan 14, 2024

Translate Excel formula into sql

Hi, I got issues when trying to translate the below excel formula into sql, I am not sure if it is possible:

 

max("11/30/2023",DATE(YEAR("11/30/2023"),MONTH("11/30/2023")-IF(DAY("11/30/2023")>DAY("11/30/2023"),1,0),DAY("11/30/2023")))

 

 

1 Reply

  • LainRobertson's avatar
    LainRobertson
    Silver Contributor

    sdnd2000 

     

    Hi, Jerry.

     

    This example doesn't really make any sense, since based on the constant date of "11/30/2023" throughout, both sides of the MAX() function remain identical.

     

    Given this is an SQL Server forum and not an Excel forum, we'd need you to break things down into tables, columns, sample input data and expected output before we have any idea of where to begin.

     

    The only thing I can say is that SQL Server is capable of conditional calculations, but until we have the above information from yourself, it's too hard to guess what you're trying to achieve.

     

    Cheers,

    Lain

Resources