Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert datetime in Persian in SQL Server

Tags:

I want to convert my datetime into Persian datetime in SQL Server. My datetime is in MM/DD/YYYY format. Is there any function in SQL Server to do this as when I want hijri datetime I use this

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

I'm using SQL Server 2008.

like image 756
Fraz Sundal Avatar asked Jul 15 '11 12:07

Fraz Sundal


1 Answers

Best method in SQL Server 2016

Example:

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

Answer:

1398/10/08-05:37:59

like image 152
Hamid Habibi Avatar answered Oct 15 '22 07:10

Hamid Habibi