Nov 3, 2005 #1 samsmithnz Well-known member Joined Jul 22, 2003 Messages 1,038 Location Boston Whats the VB.NET Format/Tostring equivalent in SQL? I cant find it, but Im sure Ive used it before...
Whats the VB.NET Format/Tostring equivalent in SQL? I cant find it, but Im sure Ive used it before...
Nov 3, 2005 #2 Nerseus Danner Joined Oct 22, 2002 Messages 2,547 Location Arizona, USA User Rank *Expert* In SQL Server? I use CONVERT. For example, to convert a date to US standard: Code: SELECT CONVERT(varchar, [datecolumnname], 101) [newDateColumnName] FROM... You can also use CAST, I believe. Formatting is limited, but usually gets you what you want. -ner
In SQL Server? I use CONVERT. For example, to convert a date to US standard: Code: SELECT CONVERT(varchar, [datecolumnname], 101) [newDateColumnName] FROM... You can also use CAST, I believe. Formatting is limited, but usually gets you what you want. -ner
Nov 4, 2005 #3 samsmithnz Well-known member Joined Jul 22, 2003 Messages 1,038 Location Boston I was thinking more about taking a number 3000 and returning it as a string with commas like: "3,000.00". In .NEt I could do it by doing: (3000).ToString("#,##0.00")
I was thinking more about taking a number 3000 and returning it as a string with commas like: "3,000.00". In .NEt I could do it by doing: (3000).ToString("#,##0.00")
Nov 8, 2005 #4 R rjonas Member Joined Nov 11, 2003 Messages 19 Location Hertingfordbury, Hertford, Herts, UK Hi, You can convert this to a type of Money, and then to a Varchar using a style of 1. select convert(varchar(50),convert(money,fieldname),1) from... The style of 1 gives 2 digits after the decimal point and inserts a comma between every 3 digits before the decimal point. There is a more detailed description of all the different styles here. Regards Richard
Hi, You can convert this to a type of Money, and then to a Varchar using a style of 1. select convert(varchar(50),convert(money,fieldname),1) from... The style of 1 gives 2 digits after the decimal point and inserts a comma between every 3 digits before the decimal point. There is a more detailed description of all the different styles here. Regards Richard