Reputation: 33
I need to display numbers in Arabic in a report developed in SSRS. I am able to display numbers such as 23000.00 in Arabic by setting the Language property to "ar-SA" and NumeralVariant to 3. However this doesn't work for TextBox that display date in the format dd/MM/yyyy.
Any help appreciated.
Upvotes: 1
Views: 1905
Reputation: 33
Create the following function in the SSRS report.
Public Function ToArabicNumber(input As String) As String
Dim output As String
output = input.Replace("1","١")
output = output.Replace("2","٢")
output = output.Replace("3","٣")
output = output.Replace("4","٤")
output = output.Replace("5","٥")
output = output.Replace("6","٦")
output = output.Replace("7","٧")
output = output.Replace("8","٨")
output = output.Replace("9","٩")
output = output.Replace("0","٠")
Return output
End Function
And consume in the report using expression as follows
=Code.ToArabicNumber(Format(DateTime.Today,"dd/MM/yyyy"))
Upvotes: 0
Reputation: 12243
It appears there isn't a built in way to do this, so you have to do it manually in your dataset query. I would recommend returning both a date
type and your Arabic date as a nvarchar
to retain filtering and ease of date logic. If you cannot be bothered to use the below on all your dates you could wrap the replace logic into a function:
declare @d date = '20171231';
select @d as DateValue
,convert(nvarchar(10), @d,103) as StringValue
,replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(
convert(nvarchar(10), @d,103)
,'0',N'٠')
,'1',N'١')
,'2',N'٢')
,'3',N'٣')
,'4',N'٤')
,'5',N'٥')
,'6',N'٦')
,'7',N'٧')
,'8',N'٨')
,'9',N'٩') as ArabicValue
Output:
+------------+-------------+-------------+
| DateValue | StringValue | ArabicValue |
+------------+-------------+-------------+
| 2017-12-31 | 31/12/2017 | ٣١/١٢/٢٠١٧ |
+------------+-------------+-------------+
Upvotes: 1