--:SetVar Function "AUX:MonthNameWithYear.Ext"
if exists( select * from [sysobjects] (nolock) where [type] in ('FN','TF') and [name]=N'AUX:MonthNameWithYear.Ext' )
   drop function [AUX:MonthNameWithYear.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:MonthNameWithYear.Ext]( @Year int, @Month int,
                               @Options bit = 3 )
returns nvarchar(25)
BEGIN
/*==================================================================================================
# SQLAUX scripting library | Author: Sergei Y.Kitáev
----------------------------------------------------------------------------------------------------
#
# OBTAINING LOCALIZED MONTH NAME WITH YEAR, IN FOLLOWING FORM:
# - “<Month name> YYYY”    (EN);
# - “<Month name> YYYY г.” (RU)
# (EXTENDED VERSION)
#
# === @Options: ===
# $(opt_MonthNameWithYear_PostscriptWithYearSign_AUX) = 1
# $(opt_MonthNameWithYear_PostscriptThroughSpace_AUX) = 2
# $(opt_MonthNameWithYear_Default_AUX) = 3
#
# === Usage: ===
# dbo.[AUX:MonthNameWithYear.Ext]( <Year>, <Month NO>, 0 )
# dbo.[AUX:MonthNameWithYear.Ext]( <Year>, <Month NO>, 1 )
# dbo.[AUX:MonthNameWithYear.Ext]( <Year>, <Month NO>, 3 )
# dbo.[AUX:MonthNameWithYear.Ext]( <Year>, <Month NO>, null )
#
==================================================================================================*/
if @Year is null or @Month is null or
   @Month not between 1 and 12
   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:MonthName]( @Month )+' '+CONVERT( varchar(11), @Year )
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IN_RUSSIAN:
return
   dbo.[AUX:MonthName]( @Month )+' '+CONVERT( varchar(11), @Year ) +
   case
      when @Options & 1 <> 0 then
         case
            when @Options & 2 <> 0
            then N' г.'
            else N'г.'
         end
      else ''
   end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*
IN_XLANG_1:
return
   dbo.[AUX:MonthName]( @Month )+' '+...
*/
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*
IN_XLANG_2:
return
   dbo.[AUX:MonthName]( @Month )+' '+...
*/
/*================================================================================================*/
END
GO
/*
select dbo.[AUX:MonthNameWithYear.Ext]( 2015, 10, 0 ) 'Month name with year'
select dbo.[AUX:MonthNameWithYear.Ext]( 2016, 10, 1 ) 'Month name with year'
select dbo.[AUX:MonthNameWithYear.Ext]( 2015, 10, null ) 'Month name with year'
*/
