Sunday, February 24, 2019

How to Find the Last Day of the Month



·         This is kind of Tricky because every month is not ends with same day(Day number)
Eg- January -31, February -28,29, April-30

·         As a developer we needs to use several functions or Method to retrieve the correct result

·        But Microsoft SQL server got built in function SELECT EOMONTH ( @date )
 
·         SELECT [SellStartDate] , IIF([SellStartDate] = EOMONTH([SellStartDate]), 'LastDay', '') LastDay
         FROM [Production].[Product]
 
·        But the limitation is EOMONTH() only supports for 2012 SQL server and Higher 

No comments:

Post a Comment

How to Login Azure SQL database using SSMS

How to Login Azure SQL database using SSMS You`ll be able to login Azure SQL database using your local SSMS. There are simple steps you n...