Solved

convert date column to mmddyyyy format

Posted on 2008-10-17
2
482 Views
Last Modified: 2012-05-05
Trying to convert a date column so that output is in the form of mmddyyyy.

I am doing :
rtrim(convert(char,datepart(mm,Citations.dob)))+
rtrim(convert(char,datepart(dd,Citations.dob)))+
rtrim(convert(char,datepart(year,Citations.dob)))

However output is 912008 - it is getting rid of the leading zero in the month and day
0
Comment
Question by:jbeckstrom
2 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 125 total points
ID: 22740560
select replace(convert(varchar(10), datefield, 101), '/', '')
0
 

Author Closing Comment

by:jbeckstrom
ID: 31507114
That did it.  Thanks.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question