For formatting 2 decimal places, you can use N2 and F2
Dim nNumber As Decimal = 12004587.123000
Console.WriteLine("F2: " & nNumber.ToString("F2"))
Console.WriteLine("N2: " & nNumber.ToString("N2"))
Output:
F2: 12004587.12
N2: 12,004,587.12
Wednesday, December 1, 2010
Sunday, November 21, 2010
Return 2 decimal places without rounding
This function returns 2 decimal places without rounding. This function requires to pass decimal value parameter.
private string FormatDecimal(decimal val)
{
decimal newValue = ((Int64)(val * 100)) / 100m;
return newValue.ToString("N2");
}
for example:
decimal dValue = 22221111.8055234M;
string newValue = FormatDecimal(dValue);
Output:
newValue = 22,221,111.80
private string FormatDecimal(decimal val)
{
decimal newValue = ((Int64)(val * 100)) / 100m;
return newValue.ToString("N2");
}
for example:
decimal dValue = 22221111.8055234M;
string newValue = FormatDecimal(dValue);
Output:
newValue = 22,221,111.80
Monday, August 30, 2010
Query SysObjects
select * from sysobjects
- returns all Objects in a database (e.g. tables, Views, Stored Procedures)
select * from sysobjects where type = 'U'
- returns all Tables Objects
select * from sysobjects where type = 'V'
- returns all SQL Views Objects
select * from sysobjects where type = 'P'
- returns all SQL Stored Procedure Objects
- returns all Objects in a database (e.g. tables, Views, Stored Procedures)
select * from sysobjects where type = 'U'
- returns all Tables Objects
select * from sysobjects where type = 'V'
- returns all SQL Views Objects
select * from sysobjects where type = 'P'
- returns all SQL Stored Procedure Objects
Subscribe to:
Posts (Atom)