--:SetVar Function "AUX:DateAsString.Ext"
if exists( select * from [sysobjects] (nolock) where [type] in ('FN','TF') and [name]=N'AUX:DateAsString.Ext' )
   drop function [AUX:DateAsString.Ext]
GO
/* Translated by $SQLTRANS utility (SQL-file technology). Method author: Sergei Y.Kitáev.
** Script translation date-time: 2022-11-27 00:29:27.24 (stamp of SQL-file generation). */
create function [AUX:DateAsString.Ext]( @Date datetime2,
                               @Options bit = 3 )
returns nvarchar(50)
BEGIN
/*==================================================================================================
# SQLAUX scripting library | Author: Sergei Y.Kitáev
----------------------------------------------------------------------------------------------------
#
# DATE AS STRING REPRESENTATION:
# - “MM/DD/YYYY”    (EN);
# - “DD.MM.YYYY г.” (RU)
# (EXTENDED VERSION)
#
# === @Options: ===
# $(opt_MonthNameWithYear_PostscriptWithYearSign_AUX) = 1
# $(opt_MonthNameWithYear_PostscriptThroughSpace_AUX) = 2
# $(opt_DateAsString_Default_AUX) = $(opt_MonthNameWithYear_Default_AUX) = 3
#
# === Usage: ===
# dbo.[AUX:DateAsString.Ext]( <Date>, null, null )
# dbo.[AUX:DateAsString.Ext]( <Date>, 1, null )
# dbo.[AUX:DateAsString.Ext]( <Date>, 1, 0 )
#
==================================================================================================*/
if @Date is null return null
----------------------------------------------------------------------------------------------------
if @Options is null set @Options=3
----------------------------------------------------------------------------------------------------
declare @LanguageId int
set @LanguageId = dbo.[AUX:ActiveLanguage]()
if @LanguageId=0 goto IN_ENGLISH
if @LanguageId=21 goto IN_RUSSIAN
--if @LanguageId=-1 goto IN_XLANG_1
--if @LanguageId=-2 goto IN_XLANG_2
goto IN_ENGLISH
----------------------------------------------------------------------------------------------------
IN_ENGLISH:
return
   dbo.[AUX:ToString.Date]( @Date )
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IN_RUSSIAN:
return
   dbo.[AUX:ToString.Date]( @Date ) +
   case
      when @Options & 2 <> 0
      then IIF( @Options & 2 <> 0,
                N' г.', N'г.' )
      else ''
   end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*
IN_XLANG_1:
return
   dbo.[AUX:ToString.Date]( @Date ) +
   ...
*/
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*
IN_XLANG_2:
return
   dbo.[AUX:ToString.Date]( @Date ) +
   ...
*/
/*================================================================================================*/
END
GO
/*
select dbo.[AUX:DateAsString.Ext]( GETDATE(), 0 ) 'Current date as string'
select dbo.[AUX:DateAsString.Ext]( GETDATE(), 1 ) 'Current date as string'
select dbo.[AUX:DateAsString.Ext]( GETDATE(), 3 ) 'Current date as string'
select dbo.[AUX:DateAsString.Ext]( GETDATE(), null ) 'Current date as string'
*/
