79738027

Date: 2025-08-17 18:28:37
Score: 0.5
Natty:
Report link

I am not sure why people didn't like the function because It works for me. I created yet another sample table as shown below and the result using this query was fantastic:

USE testDB
GO

SELECT [ID]
      ,[FirstName]
      ,[LastName]
      ,[BirthDate]
      ,FORMAT (getdate(), 'yyyy-MM-dd') as Today
      ,dbo.fn_DateDiffParts([BirthDate]) AS [CurrentAge]
      ,[Hiredate]
      ,dbo.fn_DateDiffParts([HireDate]) AS [Experience]
      ,[Department]
      ,[Salary]
  FROM [testDB].[dbo].[Employees]

Output:

enter image description here

Reasons:
  • Whitelisted phrase (-1): works for me
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: user16574790