Solved

SQL date formatting

Posted on 2013-06-18
6
254 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 250 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
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.

 

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 250 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 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