Como obter parte especifica de uma data em Consulta (SELECT) existente na linguagem de Manipulação de Dados (DML) do Azure SQL/SQL Server
This T-SQL code uses the DATEPART function to extract information specific to the current date and time, which is obtained by the GETDATE() function. I'll explain each part of the code:
SELECT DATEPART(YEAR, GETDATE()) AS CurrentYear, DATEPART(MONTH, GETDATE()) AS CurrentMonth, DATEPART(DAY, GETDATE()) AS CurrentDay
YEAR, GETDATE()) AS CurrentYear:
DATEPART(MONTH, GETDATE()) AS CurrentMonth
DATEPART(DAY, GETDATE()) AS CurrentDay
code returns three columns: "CurrentYear", "CurrentMonth", and "CurrentDay", which represent, respectively, the year, month, and day of the current date and time. This query is useful when you need to extract specific date and time information in SQL Server.
Data Scientist and Consultant for Digital and Analytics Solutions
@fabioms