Q
Problem solve Get help with specific problems with your technologies, process and projects.

Formatting dates, part 2

Continued from part 1...

To format the date as you specified in a character format would be derived from the syntax below:

DECLARE @OriginalValue AS VARCHAR(50)
DECLARE @DayValue AS VARCHAR(2)
DECLARE @MonthValue AS VARCHAR(3)
DECLARE @YearValue AS VARCHAR(4)
DECLARE @FinalValue AS VARCHAR(50)

SELECT @OriginalValue = GETDATE()
SELECT @DayValue = DATENAME(day, @OriginalValue)
SELECT @MonthValue = DATENAME(month, @OriginalValue) 
SELECT @YearValue = DATENAME(year, @OriginalValue) 
SELECT @FinalValue = @DayValue + '-' + @MonthValue + '-' + @YearValue 
No discussion of dates would be complete without mentioning some of the functions available to manipulate date values which are as follows: Along the same lines, many SQL Server Developers have had the need to obtain the date and time separate from each other as the script above outlines. Microsoft recognized these needs and is rumored to be releasing a DATE and a TIME data type in the upcoming release of SQL Server code named Yukon which is expected to be released either during the later part of 2004 or early 2005. Stay tuned!

For More Information

Dig Deeper on Microsoft SQL Server Installation

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchDataCenter

SearchDataManagement

SearchAWS

SearchOracle

SearchContentManagement

SearchWindowsServer

Close