Solved

SQL date formatting

Posted on 2013-06-18
6
252 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 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