Answered by:
regular expression indian currency ssrs

Question
-
User-282339866 posted
Hi
i need an expression to convert the currency to indian currency ssrs,.
International currency is like: 100,000,000,000.00
Indian Currency is like: 1,00,00,00,00,000.00
Please Help
Thanku
Thursday, August 9, 2012 6:39 AM
Answers
-
User-1133898271 posted
create this function and then execute it
Create FUNCTION [dbo].[udf_NumberToCurrency]
(
@InNumericValue NUMERIC(38,2)
,@InFormatType VARCHAR(10)
)
RETURNS VARCHAR(60)
AS
/*
select dbo.udf_NumberToCurrency (123411.112,'ind')
*/
BEGIN
DECLARE @RetVal VARCHAR(60)
,@StrRight VARCHAR(5)
,@StrFinal VARCHAR(60)
,@StrLength INT
SET @RetVal = ''
SET @RetVal= @InNumericValueIF(@InFormatType = 'US')
BEGIN
SET @StrFinal= CONVERT(VARCHAR(60), CONVERT(MONEY, @RetVal) , 1)
ENDELSE
IF(@InFormatType = 'IND')
BEGIN
SET @StrLength = LEN(@RetVal)
IF(@StrLength > 6)
BEGIN
SET @StrFinal = RIGHT(@RetVal,6)
SET @RetVal = SUBSTRING(@RetVal,-5,@StrLength)
SET @StrLength = LEN(@RetVal)
IF (LEN(@RetVal) > 0 AND LEN(@RetVal) < 3)
BEGIN
SET @StrFinal = @RetVal + ',' + @StrFinal
END
WHILE LEN(@RetVal) > 2
BEGIN
SET @StrRight=RIGHT(@RetVal,2)
SET @StrFinal = @StrRight + ',' + @StrFinal
SET @RetVal = SUBSTRING(@RetVal,-1,@StrLength)
SET @StrLength = LEN(@RetVal)
IF(LEN(@RetVal) > 2)
CONTINUE
ELSE
SET @StrFinal = @RetVal + ',' + @StrFinal
BREAK
END
END
ELSE
BEGIN
SET @StrFinal = @RetVal
END
END
SELECT @StrFinal = ISNULL(@StrFinal,00)
RETURN @StrFinal
END- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 9, 2012 6:50 AM -
User934013664 posted
Hi Kumar..
Refer This..
http://web4us.wordpress.com/2010/04/27/indian-currency-format/
http://www.codeproject.com/Questions/207414/Regular-Expression-for-Numeric-value-with-multiple
http://stackoverflow.com/questions/5987550/regular-expression-for-indian-currency-validation-using-javascript
http://www.dotnetspider.com/forum/212524-I-need-validation-expression-indian-currency.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 9, 2012 7:16 AM
All replies
-
User-1133898271 posted
create this function and then execute it
Create FUNCTION [dbo].[udf_NumberToCurrency]
(
@InNumericValue NUMERIC(38,2)
,@InFormatType VARCHAR(10)
)
RETURNS VARCHAR(60)
AS
/*
select dbo.udf_NumberToCurrency (123411.112,'ind')
*/
BEGIN
DECLARE @RetVal VARCHAR(60)
,@StrRight VARCHAR(5)
,@StrFinal VARCHAR(60)
,@StrLength INT
SET @RetVal = ''
SET @RetVal= @InNumericValueIF(@InFormatType = 'US')
BEGIN
SET @StrFinal= CONVERT(VARCHAR(60), CONVERT(MONEY, @RetVal) , 1)
ENDELSE
IF(@InFormatType = 'IND')
BEGIN
SET @StrLength = LEN(@RetVal)
IF(@StrLength > 6)
BEGIN
SET @StrFinal = RIGHT(@RetVal,6)
SET @RetVal = SUBSTRING(@RetVal,-5,@StrLength)
SET @StrLength = LEN(@RetVal)
IF (LEN(@RetVal) > 0 AND LEN(@RetVal) < 3)
BEGIN
SET @StrFinal = @RetVal + ',' + @StrFinal
END
WHILE LEN(@RetVal) > 2
BEGIN
SET @StrRight=RIGHT(@RetVal,2)
SET @StrFinal = @StrRight + ',' + @StrFinal
SET @RetVal = SUBSTRING(@RetVal,-1,@StrLength)
SET @StrLength = LEN(@RetVal)
IF(LEN(@RetVal) > 2)
CONTINUE
ELSE
SET @StrFinal = @RetVal + ',' + @StrFinal
BREAK
END
END
ELSE
BEGIN
SET @StrFinal = @RetVal
END
END
SELECT @StrFinal = ISNULL(@StrFinal,00)
RETURN @StrFinal
END- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 9, 2012 6:50 AM -
User934013664 posted
Hi Kumar..
Refer This..
http://web4us.wordpress.com/2010/04/27/indian-currency-format/
http://www.codeproject.com/Questions/207414/Regular-Expression-for-Numeric-value-with-multiple
http://stackoverflow.com/questions/5987550/regular-expression-for-indian-currency-validation-using-javascript
http://www.dotnetspider.com/forum/212524-I-need-validation-expression-indian-currency.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 9, 2012 7:16 AM