|
The SQL Server version
CREATE FUNCTION [dbo].[fISODate] (@InputDate DATETIME) returns varchar(8)
AS
begin
declare @Return varchar(8)
select @return =
substring(convert(varchar, @InputDate, 101),7,4) +
substring(convert(varchar, @InputDate, 101),1,2) +
substring(convert(varchar, @InputDate, 101),4,2)
return @return
end
The VBA version
Public Function fISODate(InputDate As Variant) As String
If IsNull(InputDate) Then
fISODate = "00000000"
Else
fISODate = Format(InputDate, "yyyymmdd")
End If
End Function
|
|