如何在SQL Server中转换波斯语DATETIME

zqdjd7g9  于 2022-09-18  发布在  Java
关注(0)|答案(13)|浏览(160)

我想在SQL Server中将我的日期时间转换为波斯日期时间。我的日期时间格式为MM/DD/YYYY。在SQL Server中有什么函数可以这样做吗?当我想要hijri日期时间时,我使用这个

SELECT CONVERT(VARCHAR(40), GETDATE(), 131) -- Output is 14/08/1432 5:02:01:197PM

我使用的是SQL Server 2008。

py49o6xq

py49o6xq1#

SQL Server 2016年度最佳方法

示例:

SELECT FORMAT(GETDATE(), 'yyyy/MM/dd-HH:mm:ss', 'fa')

回答:

1398/10/08-05:37:59

j7dteeu8

j7dteeu82#

我知道现在回答这个问题太晚了,但我已经提交了我使用了很长时间的函数,没有任何错误,我见过的所有其他方法都有间歇年份的问题:

CREATE FUNCTION [CalculatePersianDate] ( @intDate DATETIME )
RETURNS NVARCHAR(max)
BEGIN

DECLARE @shYear AS INT ,@shMonth AS INT ,@shDay AS INT ,@intYY AS INT ,@intMM AS INT ,@intDD AS INT ,@Kabiseh1 AS INT ,@Kabiseh2 AS INT ,@d1 AS INT ,@m1 AS INT, @shMaah AS NVARCHAR(max),@shRooz AS NVARCHAR(max),@DayCnt AS INT
DECLARE @DayDate AS NVARCHAR(max)

SET @intYY = DATEPART(yyyy, @intDate)

IF @intYY < 1000 SET @intYY = @intYY + 2000

SET @intMM = MONTH(@intDate)
SET @intDD = DAY(@intDate)
SET @shYear = @intYY - 622
SET @DayCnt = 5

IF ( ( @intYY - 1992 ) % 4 = 0) SET @Kabiseh1 = 0 ELSE SET @Kabiseh1 = 1

IF ( ( @shYear - 1371 ) % 4 = 0) SET @Kabiseh2 = 0 ELSE SET @Kabiseh2 = 1

SET @m1 = 1
SET @d1 = 1
SET @shMonth = 10
SET @shDay = 11

IF ( ( @intYY - 1993 ) % 4 = 0 ) SET @shDay = 12

WHILE ( @m1 != @intMM ) OR ( @d1 != @intDD )
BEGIN

  SET @d1 = @d1 + 1
  SET @DayCnt = @DayCnt + 1

  IF 
  (@d1 = 32 AND (@m1 = 1 OR @m1 = 3 OR @m1 = 5 OR @m1 = 7 OR @m1 = 8 OR @m1 = 10 OR @m1 = 12))
  OR
  (@d1 = 31 AND (@m1 = 4 OR @m1 = 6 OR @m1 = 9 OR @m1 = 11))
  OR
  (@d1 = 30 AND @m1 = 2 AND @Kabiseh1 = 1)
  OR
  (@d1 = 29 AND @m1 = 2 AND @Kabiseh1 = 0)
  BEGIN
    SET @m1 = @m1 + 1
    SET @d1 = 1
  END

  IF @m1 > 12
  BEGIN
    SET @intYY = @intYY + 1
    SET @m1 = 1
  END

  IF @DayCnt > 7 SET @DayCnt = 1

 SET @shDay = @shDay + 1

  IF
  (@shDay = 32 AND @shMonth < 7)
  OR
  (@shDay = 31 AND @shMonth > 6 AND @shMonth < 12)
  OR
  (@shDay = 31 AND @shMonth = 12 AND @Kabiseh2 = 1)
  OR
  (@shDay = 30 AND @shMonth = 12 AND @Kabiseh2 = 0)
  BEGIN
    SET @shMonth = @shMonth + 1
    SET @shDay = 1
  END

  IF @shMonth > 12
  BEGIN
    SET @shYear = @shYear + 1
    SET @shMonth = 1
  END

END

IF @shMonth=1 SET @shMaah=N'فروردین'
IF @shMonth=2 SET @shMaah=N'اردیبهشت'
IF @shMonth=3 SET @shMaah=N'خرداد'
IF @shMonth=4 SET @shMaah=N'تیر'
IF @shMonth=5 SET @shMaah=N'مرداد'
IF @shMonth=6 SET @shMaah=N'شهریور'
IF @shMonth=7 SET @shMaah=N'مهر'
IF @shMonth=8 SET @shMaah=N'آبان'
IF @shMonth=9 SET @shMaah=N'آذر'
IF @shMonth=10 SET @shMaah=N'دی'
IF @shMonth=11 SET @shMaah=N'بهمن'
IF @shMonth=12 SET @shMaah=N'اسفند'

IF @DayCnt=1 SET @shRooz=N'شنبه'
IF @DayCnt=2 SET @shRooz=N'یکشنبه'
IF @DayCnt=3 SET @shRooz=N'دوشنبه'
IF @DayCnt=4 SET @shRooz=N'سه‌شنبه'
IF @DayCnt=5 SET @shRooz=N'چهارشنبه'
IF @DayCnt=6 SET @shRooz=N'پنجشنبه'
IF @DayCnt=7 SET @shRooz=N'جمعه'

--SET @DayDate = @shRooz + " " + LTRIM(STR(@shDay,2)) + " " + @shMaah + " " + STR(@shYear,4)
--پنجشنبه 17 اردیبهشت 1394

/*
SET @DayDate = LTRIM(STR(@shDay,2)) + " " + @shMaah + " " + STR(@shYear,4)
--17 اردیبهشت 1394

SET @DayDate = STR(@shYear,4) + "/"+LTRIM(STR(@shMonth,2)) + "/" + LTRIM(STR(@shDay,2))
--1394/2/17

--1394/02/17

* /

SET @DayDate = REPLACE(RIGHT(STR(@shYear, 4), 4), ' ', '0') + '/'+ REPLACE(STR(@shMonth, 2), ' ', '0') + '/' + REPLACE(( STR(@shDay,2) ), ' ', '0')
RETURN @DayDate
END

定制函数的结果真的很容易。采用自:this page

gojuced7

gojuced73#

我知道为时已晚,但对于像我这样遇到这种麻烦的人来说,这可能是有用的。

您应该为该转换编写一个SQL函数,如下所示:Converting Gregorian to Persian Date

然后像这样使用它:

SELECT dbo.[UDF_Gregorian_To_Persian]('2013-08-24')
7nbnzgx9

7nbnzgx94#

试试这个:

select format(getdate() , 'yyyy/MM/dd', 'fa-ir')
slhcrj9b

slhcrj9b5#

您可以使用以下代码转换日期。这一实用而重要的方法已被添加到2012版的SQL中,可以使用。

SELECT FORMAT(GETDATE(), 'yyyy/MM/dd-HH:mm:ss', 'fa')

Result: 1400/02/08-05:08:51

SELECT cast( FORMAT(GETDATE(), 'yyyyMMdd', 'fa') as int)

Result: 14000208

您可以使用以下格式获取HIGRI日期:

SELECT FORMAT(GETDATE(), N'yyyy/MM/dd', N'ar')
   Result:  1443/06/19
aoyhnmkz

aoyhnmkz6#

开箱即用,没有。

您必须编写自己的UDF,但是CodePlexanother上有一个UDF

3vpjnl9f

3vpjnl9f7#

我认为最好的解决方案是使用SQLCLR-Jalali-Date-Utility。它有一个直观的安装指南和易于使用的功能。此外,您可以不受任何限制地定义折算日期的格式。事实上,您可以使用standard time formatting来定义转换日期的形状。

GitHub页面中提供了几个示例。

select dbo.GregorianToJalali(GETDATE(),'yyyy/MM/dd hh:mm:ss tt') -- returns 1395/07/01 03:04:33 ب ظ
xdyibdwo

xdyibdwo8#

这是SQL 2016+中的波斯日历函数

ALTER FUNCTION [dbo].[PCalendar](@date datetime)
RETURNS @ret TABLE (
   ly int,
    y int,
    m int,
    mname nvarchar(15),
    d int,
    dy int,
    dw int,
    dname nvarchar(10),
    hh int,
    mm int,
    ss int,
    mss int,
    dt datetime,
    t nvarchar(3))
as
BEGIN
    DECLARE @format varchar(19);
    set @format = 'yyyy/MM/dd HH:mm:ss';
    DECLARE @y int;
    DECLARE @m int;
    DECLARE @d int;
    DECLARE @dy int;
    DECLARE @dw int;
    DECLARE @hh int;
    DECLARE @mm int;
    DECLARE @ss int;
    DECLARE @ms int;
    DECLARE @ldt varchar(8);
    set @y = DATEPART(YEAR, FORMAT(@date, @format, 'fa')) ;
    set @m = DATEPART(MONTH, FORMAT(@date, @format, 'fa'));
    set @d = DATEPART(DAY, FORMAT(@date, @format, 'fa')) ;
    set @dy = DATEPART(DAYOFYEAR, FORMAT(@date, @format, 'fa'));
    set @dw = DATEPART(WEEKDAY, FORMAT(@date,@format, 'fa'));
    set @hh = DATEPART(HOUR, @date) ;
    set @mm = DATEPART(MINUTE, @date) ;
    set @ss = DATEPART(SECOND, @date);
    set @ms = DATEPART(MILLISECOND, @date);
    set @ldt =DATEPART(year, FORMAT(@date, @format, 'en'));
    DECLARE @_w nvarchar(10);

    set @_w = CASE
        WHEN @dw=1 THEN N'جمعه'
        WHEN @dw=2 THEN N'شنبه'
        WHEN @dw=3 THEN N'یکشنبه'
        WHEN @dw=4 THEN N'دوشنبه'
        WHEN @dw=5 THEN N'سه شنبه'
        WHEN @dw=6 THEN N'چهارشنبه'
        ELSE N'پنج شنبه'
    END;    
DECLARE @_m nvarchar(15);
set @_m = CASE
    WHEN @m=1 THEN N'فروردین'
    WHEN @m=2 THEN N'اردیبهشت'
    WHEN @m=3 THEN N'خرداد'
    WHEN @m=4 THEN N'تیر'
    WHEN @m=5 THEN N'مرداد'
    WHEN @m=6 THEN N'شهریور'
    WHEN @m=7 THEN N'مهر'
    WHEN @m=8 THEN N'آبان'
    WHEN @m=9 THEN N'آذر'
    WHEN @m=10 THEN N'دی'
    WHEN @m=11 THEN N'بهمن'
    ELSE N'اسفند'
END;    
set @_m = @_m+N' ماه';
INSERT INTO @ret 
    SELECT 
    IIF(@y % 33 in (1,5,9,13,17,22,26,30) , 1 , 0) as ly, 
    @y as y, 
    @m as m, 
    @_m as mname, 
    @d as d, 
    @dy as dy, 
    @dw as dw, 
    @_w as dname,
    @hh as hh, 
    @mm as mm, 
    @ss as ss, 
    @ms as mss, 
    @date as dt,
    IIF(@hh > 12 , N'ب.ظ','ق.ظ') as t;
RETURN;

结束

j8yoct9x

j8yoct9x9#

您可以使用此函数将其转换为Shamsi。

第一个函数。

CREATE FUNCTION [dbo].[ToPersianDate](@dt [datetime])
RETURNS [nvarchar](10) WITH EXECUTE AS CALLER
AS 
EXTERNAL NAME [PersianSQLFunctions].[UserDefinedFunctions].[ToPersianDate]
GO

第二个功能。

SET ANSI_NULLS OFF
GO

SET QUOTED_IDENTIFIER OFF
GO

CREATE FUNCTION [dbo].[ToPersianDate](@dt [datetime])
RETURNS [nvarchar](10) WITH EXECUTE AS CALLER
AS 
EXTERNAL NAME [PersianSQLFunctions].[UserDefinedFunctions].[ToPersianDate]
GO

第三个功能。

CREATE FUNCTION [dbo].[fnToShamsiDate]
(
    @d DateTime
)
RETURNS NVARCHAR(10)
AS
BEGIN
    -- Declare the return variable here
    DECLARE @RV NVARCHAR(10)
    IF (@d) IS NULL RETURN NULL;
    ELSE SELECT @RV = DBO.ToPersianDate(@D);
    -- Return the result of the function
    RETURN @RV

END
GO

你还可以从这个函数中找到Shamsi月份

create function [dbo].[fnGetShamsiMonth]
(
    @GregorianDate date
)
returns nvarchar(2)
as
begin
    declare @ShamsiMonth nvarchar(2), @ShamsiDate nvarchar(10);

    set @ShamsiDate = confsys.dbo.fnToShamsiDate(@GregorianDate);

    set @ShamsiMonth = SUBSTRING(@ShamsiDate,6,2);

    return @ShamsiMonth
end
GO

示例

select confsys.dbo.fnToShamsiDate(getdate())

结果为1397/12/29

得到Shamsi月份

select confsys.dbo.fnGetShamsiMonth(GETDATE());
k97glaaz

k97glaaz10#

功能:SQL SERVER中完全转换波斯语(Shamsi/Jalali)字符串**到格里高利(米拉迪)**DATETIME:

> create or ALTER Function [dbo].[Func_ShamsiToMiladi] (@Date
> Varchar(23) ) RETURNS DateTime BEGIN
> -- ============================================================== 
> -- SELECT [dbo].[Func_ShamsiToMiladi] ('1356-09-20 05:35:00.000')
> --
> -- Output :                              '1977-12-11 02:05:00.000'
> -- ==============================================================
> -- BY: Shahrokh Vazifedan Hobabname@Gmail.COM     DECLARE  @PersianDate Varchar(23)    SET  @PersianDate =  @Date  
>  
>     DECLARE @Year     INT = SUBSTRING(@PersianDate, 1, 4)  
>     DECLARE @Month    INT = SUBSTRING(@PersianDate, 6, 2)
>     DECLARE @Day      INT = SUBSTRING(@PersianDate, 9, 2)
>     DECLARE @DiffYear INT = @Year - 1350
>     DECLARE @Time varchar(13) = SUBSTRING(@PersianDate, 11, 13)
>    
> 
>     DECLARE @Days INT = @DiffYear * 365.24 +
>     CASE WHEN @Month < 7 THEN (@Month - 1) * 31
>          ELSE 186 + (@Month - 7) * 30 END + @Day
> 
>     DECLARE @StartDate DATETIME = '03/21/1971'
>     DECLARE @ResultDate DATE = @StartDate + @Days
> 
>     DECLARE @TempDate varchar(23) = Convert(  Nvarchar(10) , @ResultDate ,120)   + @Time      DECLARE @OffSET_First_half_in_Year
> INT;      SET @OffSET_First_half_in_Year = iif( Substring(Convert(
> Nvarchar(50), @TempDate,120) ,6,16) Between '03-20 20:30' and '09-22
> 20:30' , -60 ,0)
>           RETURN dateadd(MINUTE,  @OffSET_First_half_in_Year + (-1)*datediff(MINUTE, getutcdate(), getdate()),@TempDate )   END

创建者:Shahrokh Vazifedan-Sari@伊朗:)
电子邮件:HobabName@gmail.com

57hvy0tb

57hvy0tb11#

要将日期转换为波斯语,请尝试以下代码:

DECLARE @DateString NVARCHAR(200)='2022/09/07';
SELECT FORMAT(CAST(@DateString AS DATE),'yyyy/MM/dd','fa');
iyr7buue

iyr7buue12#

CREATE   FUNCTION [dbo].[MITSH] (@MDate  DateTime)  
RETURNS Varchar(10)
AS  
BEGIN 
   DECLARE @SYear  as Integer
   DECLARE @SMonth  as Integer
   DECLARE @my_mah varchar(2)
   declare @my_day varchar(2)
   DECLARE @SDay  as Integer
   DECLARE @AllDays  as float
   DECLARE @ShiftDays  as float
   DECLARE @OneYear  as float
   DECLARE @LeftDays  as float
   DECLARE @YearDay  as Integer
   DECLARE @Farsi_Date  as Varchar(100) 
   SET @MDate=@MDate-CONVERT(char,@MDate,114)

  SET @ShiftDays=466699   +2
  SET @OneYear= 365.24199

   SET @SYear = 0
   SET @SMonth = 0
   SET @SDay = 0
   SET @AllDays  = CAst(@Mdate as Real)

   SET @AllDays = @AllDays + @ShiftDays

  SET @SYear = (@AllDays / @OneYear) --trunc
  SET @LeftDays = @AllDays - @SYear * @OneYear

  if (@LeftDays < 0.5)
  begin
    SET @SYear=@SYear+1
    SET @LeftDays = @AllDays - @SYear * @OneYear
  end;

  SET @YearDay = @LeftDays --trunc
  if (@LeftDays - @YearDay) >= 0.5 
    SET @YearDay=@YearDay+1

  if ((@YearDay / 31) > 6 )
  begin
    SET @SMonth = 6
    SET @YearDay=@YearDay-(6 * 31)
    SET @SMonth= @SMonth+( @YearDay / 30)
    if (@YearDay % 30) <> 0 
      SET @SMonth=@SMonth+1
    SET @YearDay=@YearDay-((@SMonth - 7) * 30)
  end 
  else
  begin
    SET @SMonth = @YearDay / 31
    if (@YearDay % 31) <> 0 
      SET @SMonth=@SMonth+1 
    SET @YearDay=@YearDay-((@SMonth - 1) * 31)
  end
  SET @SDay = @YearDay
  SET @SYear=@SYear+1

if @SMonth <10 begin 
   set @my_mah='0'+str(@SMonth,1)
end else begin
    set @my_mah = str(@SMonth,2)
end   
if @sday <10 begin
   set @my_day='0'+str(@Sday,1)
end else begin
    set @my_day = str(@Sday,2)
end   

 SET @Farsi_Date =   CAST (@SYear   as VarChar(10)) + '/' + @my_mah + '/' + @my_day
 Return @Farsi_Date

END

A FOR EXEC函数

SELECT DBO.MITSH(GETDATE())

for example date is 2020-09-25

  resualt =>>>>  1399/07/04
bjg7j2ky

bjg7j2ky13#

SQL 2008和2008 R2及更低版本的Shamsi Date的完整功能:

CREATE FUNCTION [dbo].[PersToJul](@iYear int,@iMonth int,@iDay int)
RETURNS bigint
AS
Begin

Declare @PERSIAN_EPOCH  as int
Declare @epbase as bigint
Declare @epyear as bigint
Declare @mdays as bigint
Declare @Jofst  as Numeric(18,2)
Declare @jdn bigint

Set @PERSIAN_EPOCH=1948321
Set @Jofst=2415020.5

If @iYear>=0 
    Begin
        Set @epbase=@iyear-474 
    End
Else
    Begin
        Set @epbase = @iYear - 473 
    End
    set @epyear=474 + (@epbase%2820) 
If @iMonth<=7
    Begin
        Set @mdays=(Convert(bigint,(@iMonth) - 1) * 31)
    End
Else
    Begin
        Set @mdays=(Convert(bigint,(@iMonth) - 1) * 30+6)
    End
    Set @jdn =Convert(int,@iday) + @mdays+ Cast(((@epyear * 682) - 110) / 2816 as int)  + (@epyear - 1) * 365 + Cast(@epbase / 2820 as int) * 1029983 + (@PERSIAN_EPOCH - 1) 
    RETURN @jdn
End
--------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
GO
CREATE FUNCTION [dbo].[GrToPers] (@date datetime)
Returns nvarchar(50)
AS 
Begin
    Declare @depoch as bigint
    Declare @cycle  as bigint
    Declare @cyear  as bigint
    Declare @ycycle as bigint
    Declare @aux1 as bigint
    Declare @aux2 as bigint
    Declare @yday as bigint
    Declare @Jofst  as Numeric(18,2)
    Declare @jdn bigint

    Declare @iYear   As Integer
    Declare @iMonth  As Integer
    Declare @iDay    As Integer

    Set @Jofst=2415020.5
    Set @jdn=Round(Cast(@date as int)+ @Jofst,0)

    Set @depoch = @jdn - [dbo].[PersToJul](475, 1, 1) 
    Set @cycle = Cast(@depoch / 1029983 as int) 
    Set @cyear = @depoch%1029983 

    If @cyear = 1029982
       Begin
         Set @ycycle = 2820 
       End
    Else
       Begin
        Set @aux1 = Cast(@cyear / 366 as int) 
        Set @aux2 = @cyear%366 
        Set @ycycle = Cast(((2134 * @aux1) + (2816 * @aux2) + 2815) / 1028522 as int) + @aux1 + 1 
      End

    Set @iYear = @ycycle + (2820 * @cycle) + 474 

    If @iYear <= 0
      Begin 
        Set @iYear = @iYear - 1 
      End
    Set @yday = (@jdn - [dbo].[PersToJul](@iYear, 1, 1)) + 1 
    If @yday <= 186 
       Begin
         Set @iMonth = CEILING(Convert(Numeric(18,4),@yday) / 31) 
       End
    Else
       Begin
          Set @iMonth = CEILING((Convert(Numeric(18,4),@yday) - 6) / 30)  
       End
       Set @iDay = (@jdn - [dbo].[PersToJul](@iYear, @iMonth, 1)) + 1 

      Return Convert(nvarchar(50),@iDay) + '-' +   Convert(nvarchar(50),@iMonth) +'-' + Convert(nvarchar(50),@iYear)
End
--------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
GO
CREATE FUNCTION [dbo].[JulToGre] (@jdn bigint)
Returns nvarchar(11)
AS
Begin
    Declare @Jofst  as Numeric(18,2)
    Set @Jofst=2415020.5
    Return Convert(nvarchar(11),Convert(datetime,(@jdn- @Jofst),113),110)
End
--------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
GO
CREATE FUNCTION [dbo].[COnvertOToN](@StrMyNum NVARCHAR(2))
    RETURNS NVARCHAR(2)
AS
BEGIN
    DECLARE @MyNunInStr NVARCHAR(10)
    SET @MyNunInStr = @StrMyNum
    IF LEN(@MyNunInStr) < 2 
    BEGIN
     SET @MyNunInStr = '0' + @MyNunInStr
    END
RETURN @MyNunInStr
END
--------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
GO
-- Changing Date Format
CREATE FUNCTION [dbo].[RevDateShm](@StrDateShamsi NVARCHAR(10), @Seperator CHAR(1))
RETURNS NVARCHAR(10)
AS
BEGIN
    DECLARE @StrDayOfMotn NVARCHAR(10)
    DECLARE @StrMothOfYear NVARCHAR(10)
    DECLARE @StrYearOfYear NVARCHAR(10)

        SET @StrDayOfMotn = dbo.COnvertOToN(REPLACE(SUBSTRING(@StrDateShamsi , 1 , ((SELECT CHARINDEX('-' , @StrDateShamsi , 0)))), '-' , ''))
        SET  @StrMothOfYear = dbo.COnvertOToN(REPLACE(SUBSTRING(@StrDateShamsi , ((CHARINDEX('-' , @StrDateShamsi , 0)  )) , 3) , '-' , ''))
        SET @StrYearOfYear = RIGHT(@StrDateShamsi , 4)

    return (@StrYearOfYear + @Seperator + @StrMothOfYear + @Seperator + @StrDayOfMotn)
END
--------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
GO
CREATE FUNCTION [dbo].[ConvertShamsiToMiladiDate](@InputShamsiDateString nvarchar(10))
RETURNS datetime
AS
BEGIN
    declare @InputShamsiDateString1 nvarchar(10)
    declare @yearm int
    declare @monthm int
    declare @daym int
    set @yearm = CONVERT(int , SUBSTRING(@InputShamsiDateString , 1 , 4))
    set @monthm = CONVERT(int , SUBSTRING(@InputShamsiDateString , 6 , 2))
    set @daym = CONVERT(int , SUBSTRING(@InputShamsiDateString , 9 , 2))
    return (select dbo.[JulToGre](dbo.[PersToJul](@yearm,@monthm ,@daym )))
END
--------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
GO
-- The Latest And Main Function
CREATE FUNCTION [dbo].[GetShmsiDate](@InputMiladiDate DateTime , @MySeperatorChar char(1))
RETURNS NVARCHAR(10)
AS
BEGIN
    return (select dbo.RevDateShm(dbo.GrToPers(@InputMiladiDate), @MySeperatorChar) AS ShamsiDateOfLog)
END
GO

如何使用:

SELECT dbo.GetShmsiDate(GETDATE() , N'/') AS ShamsiDate1, 
       dbo.GetShmsiDate(GETDATE() , N'-') AS ShamsiDate2

结果:

|ShamsiDate1|ShamsiDate2|
|-----------|-----------|
|1400/11/03 | 1400-11-03|

相关问题