Last active
March 18, 2021 12:24
-
-
Save afruzan/062d58b1b12d4366bcb273338ea37631 to your computer and use it in GitHub Desktop.
Iran Official Date And Time (Jalali calendar - Tehran TimeZone) Solution in SQL raw and linq query (ef core 5).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @myutcdate as datetime2 = CAST('2021-03-17 22:00' AS datetime2); | |
select | |
FORMAT(SWITCHOFFSET(@myutcdate, '+03:30'), 'yyyy-MM-dd', 'fa') as 'get iran date', | |
FORMAT(SWITCHOFFSET(@myutcdate, '+03:30'), 'yyyy-MM', 'fa') as 'get iran year-month', | |
CAST(FORMAT(SWITCHOFFSET(@myutcdate, '+03:30'), 'dd', 'fa') as int) as 'get iran day', | |
CAST(FORMAT(@myutcdate, 'dd', 'fa') as int) as 'invalid time-zone results in invalid date.' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Format function is not deterministic and cannot be used in StoredComputedColumns. so for last select we should use GregorianToJalali or another way.