Solved

SQL Dateformat problem

Posted on 2006-11-13
1
869 Views
Last Modified: 2008-01-09
I wish to convert a datetime value to a string in the format YYYYMMDD where YYYY is the year, MM is the month with leading zero if appliccable and DD is the day, also with leading zero if appliccable.

EG. for 4th may 2006 the string would be 20060504

I am using microsoft SQL Server (2005)

Thanks,

Roger
0
Comment
Question by:alcindor
1 Comment
 
LVL 10

Accepted Solution

by:
Kinger247 earned 500 total points
Comment Utility
Try : select convert(varchar(8), convert(datetime, getdate(), 112), 112)

where getdate() is your date !
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now