I used this code to convert date to “Arabic” culture
select FORMAT(CAST('2024-06-03' AS DATE), 'yyyy/MM/dd HH:mm:ss', 'ar-SA')
but the result is wrong date. this date ‘2024-06-03’ actually is ‘1445/11/25’ in Arabic but this is ‘1445/11/26’ what is i got.
I found a SQL function at Github but the problem was same and this problem is bigger than i think because i test it in c# console with this code
DateTime.Parse("2024-06-03").ToString("yyyy/MM/dd", new System.Globalization.CultureInfo("ar-SA"))
and saw the wrong converted date here again.
I have no idea how i can fix it, can anybody help me at this situation?
I used this types of casting
format(PARSE('[date]' as date), 'yyyy/MM/dd', 'ar-SA')
format(CAST('[date]' as date), 'yyyy/MM/dd', 'ar-SA')
format(CONVERT(DATE, '[date]'), 'yyyy/MM/dd', 'ar-SA')
Dev3 KaraAfzar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
10