Solved

SQL Dateformat problem

Posted on 2006-11-13
1
873 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
ID: 17930204
Try : select convert(varchar(8), convert(datetime, getdate(), 112), 112)

where getdate() is your date !
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 25 111
word0 challenge 4 71
t-sql sp_addlinkedserver possible risks 3 95
Way to decrease size of apk file 9 88
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

808 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