Wednesday, July 6, 2022

SQL SERVER find month year from date

 CAST(MONTH(@Batch_Start_date) AS INT)

SET @Year = CAST(YEAR(@Batch_Start_date) AS INT)


or


select year('2022-01-01')  or select month('2022-01-01') 



reference:-https://www.w3schools.com/sql/func_sqlserver_cast.asp

No comments:

Post a Comment