September 23, 2004 at 6:48 am
I'm new to Sql Server but used to work in Access, Sybase, Oracle.
I'm looking for something like format(value, 'YYYYMMDD') to format a date in a custom format and format(value,'000.00') to have a custom number-format. Is this possible in sql server?
September 23, 2004 at 6:53 am
Look up CONVERT in BOL ( SQL Server Books Online).
September 24, 2004 at 9:27 am
Many people have asked through this forum about a FORMAT() function. Unfortunately, you'll have to write your own. However, to get you started with the CONVERT() function, here are a few examples that address your specific examples.
DECLARE @date datetime, @inum int, @fnum float
SET @date = GetDate()
SET @inum = 123456
SET @fnum = 12345.6
SELECT Convert(varchar(8), @date, 112) AS DateFormat,
Convert(varchar(20), Convert(money, @inum), 0) AS NumFormat1,
Convert(varchar(20), Convert(money, @fnum), 0) AS NumFormat2
September 25, 2004 at 12:52 am
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy