--:SetVar Function "AUX:WeekDayName.Ext"
if exists( select * from [sysobjects] (nolock) where [type] in ('FN','TF') and [name]=N'AUX:WeekDayName.Ext' )
   drop function [AUX:WeekDayName.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:WeekDayName.Ext]( @WeekDayNo int, @Options int=0 )
returns nvarchar(15)
BEGIN
/*==================================================================================================
# SQLAUX scripting library | Author: Sergei Y.Kitáev
----------------------------------------------------------------------------------------------------
#
# OBTAINING LOCALIZED WEEK DAY NAME BY ITS NUMBER [1..7] (EXT.VERSION):
#
# === @Options: ===
# $(opt_MonthName_InGenitiveCase_AUX) = 1
#
# === Usage: ===
# dbo.[AUX:WeekDayName.Ext]( <Week-day NO>, null )
# dbo.[AUX:WeekDayName.Ext]( <Week-day NO>, 0 )
# dbo.[AUX:WeekDayName.Ext]( <Week-day NO>, 1 ) -- from Sunday
# dbo.[AUX:WeekDayName.Ext]( <Week-day NO>, 2 ) -- from Monday
#
==================================================================================================*/
if @WeekDayNo is null return null
----------------------------------------------------------------------------------------------------
if @Options is null set @Options=0
----------------------------------------------------------------------------------------------------

if @Options & 1 <> 0
   return ( select [Name] from [AUX:WeekDayList]() where [FromSundayNo] = @WeekDayNo )
if @Options & 2 <> 0
   return ( select [Name] from [AUX:WeekDayList]() where [FromMondayNo] = @WeekDayNo )

return ( select [Name] from [AUX:WeekDayList]() where [NO] = @WeekDayNo )

/*================================================================================================*/
END
GO
/*
select dbo.[AUX:WeekDayName.Ext]( 1, null ) 'Week day name (#1)'
select dbo.[AUX:WeekDayName.Ext]( 1, 0 ) 'Week day name (#1)'
select dbo.[AUX:WeekDayName.Ext]( 1, 1 ) 'Week day name (#1-from-Sunday)'
select dbo.[AUX:WeekDayName.Ext]( 1, 2 ) 'Week day name (#1-from-Monday)'
*/
