?
Solved

Format date as MMDDYYYY

Posted on 2011-09-29
5
Medium Priority
?
346 Views
Last Modified: 2012-05-12
I need to always return the date as 8 characters

so 8/27/2011

would be

09272011
0
Comment
Question by:lrbrister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 2000 total points
ID: 36818042
select CONVERT(varchar(8),getdate(),112)  -- yyyymmdd

for your requirements:

select right(CONVERT(varchar(8),getdate(),112),4) + LEFT(CONVERT(varchar(8),getdate(),112),4)

0
 
LVL 33

Assisted Solution

by:knightEknight
knightEknight earned 2000 total points
ID: 36818043
but replace getdate() with your date column name
0
 
LVL 3

Expert Comment

by:kinsey
ID: 36818047
select convert(varchar, datecolumnname,112) gives YYYYMMDD
so

select right(convert(varchar,getdate(),112),4)+left(convert(varchar,getdate(),112),4)

give MMDDYYY
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 36818057
another option:

select REPLACE( CONVERT(varchar(10),getdate(),101), '/', '' )
0
 

Author Closing Comment

by:lrbrister
ID: 36818094
Thanks
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

752 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