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 + '-' + @YearValueNo discussion of dates would be complete without mentioning some of the functions available to manipulate date values which are as follows:
For More Information
- Dozens more answers to tough SQL Server questions from Greg Robidoux and Jeremy Kadlec are available here.
- The Best Microsoft SQL Server Web Links: tips, tutorials, scripts, and more.
- Have a SQL Server tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical SQL Server questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, SQL Server, DB2, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
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.