Solved

date time in sql

Posted on 2013-01-09
5
297 Views
Last Modified: 2013-01-10
How to convert 11/26/2012 to 112612 ?
0
Comment
Question by:VBdotnet2005
[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
5 Comments
 
LVL 3

Expert Comment

by:Crower
ID: 38760011
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 1), '/', '')

this help you?
0
 
LVL 22

Accepted Solution

by:
Steve Wales earned 125 total points
ID: 38760026
Expanding on Crower's offering.

If the date you've got is a text column somewhere, rather than already a datetime:

SELECT REPLACE(CONVERT(VARCHAR(10), convert(datetime, '11/26/12', 1), 1), '/', '')

(Or replace the literal of the date with the column name)
0
 
LVL 34

Assisted Solution

by:Paul MacDonald
Paul MacDonald earned 125 total points
ID: 38760036
cast(month([yourdate]) as varchar) + cast(DAY([yourdate]) as varchar) + cast(YEAR([yourdate]) as varchar)
0
 
LVL 32

Assisted Solution

by:Ephraim Wangoya
Ephraim Wangoya earned 125 total points
ID: 38760082
try

select replace(convert(varchar(8), YourDateColumn, 10), '-', '')
0
 
LVL 21

Assisted Solution

by:Alpesh Patel
Alpesh Patel earned 125 total points
ID: 38761788
for SQL Server 2012


SELECT FORMAT(GETDATE(),'MMddyy')
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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…
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 combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

749 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