Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL date formatting

Posted on 2013-06-18
6
Medium Priority
?
263 Views
Last Modified: 2013-06-18
Hello all,
I have a date time column DispensedDate which has values like :2012-06-07 00:00:00.000.
How to convert this to MM/DD/YY in a query
0
Comment
Question by:Star79
[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
6 Comments
 
LVL 11

Accepted Solution

by:
Guru Ji earned 1000 total points
ID: 39257510
SELECT convert(varchar, getdate(), 101) – mm/dd/yyyy - 10/02/2008
0
 
LVL 11

Expert Comment

by:Guru Ji
ID: 39257513
replace getdate() with your date column
0
 
LVL 2

Expert Comment

by:Averitteg
ID: 39257516
Try:
SELECT CAST(table.DispensedDate AS DATE) AS DispensedDate
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:Star79
ID: 39257524
hello all,
I need it like
MM/DD/YY
Note the year its only YY
0
 
LVL 15

Assisted Solution

by:tim_cs
tim_cs earned 1000 total points
ID: 39257582
Replace his 101 with just 1.
0
 
LVL 2

Expert Comment

by:Averitteg
ID: 39257618
Select CONVERT(VARCHAR(11),DispensedDate,1) as Dispensed Date from table

Tim_cs was correct: this version works just fine in a sql query. Tested success in Sql 2008.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

670 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