If you do not want to adjust the value, you can do this:
DECLARE @nbr INT=13901210
SELECT
LEFT(@nbr,4)+'/'+
SUBSTRING(CAST(@nbr AS VARCHAR(10)),5,2)+'/'+
RIGHT(@nbr,2)
And then the function will look like this:
CREATE FUNCTION [dbo].[GetDateFormatForInt] (@nbr int)
RETURNS varchar(10)
AS
BEGIN
RETURN
LEFT(@nbr,4)+'/'+
SUBSTRING(CAST(@nbr AS VARCHAR(10)),5,2)+'/'+
RIGHT(@nbr,2);
END
This will only work if it's a 10 digit number
source
share