Solved

What is the best way to convert a  sql statement from one format to another? What function should i use?

Posted on 2014-10-08
5
95 Views
Last Modified: 2014-10-23
What is the best way to convert a  sql statement from one format to another? What function should i use?
0
Comment
Question by:vbnetcoder
  • 2
  • 2
5 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40368587
Depends.  Define 'one format' and 'another'.
0
 
LVL 46

Expert Comment

by:Vitor Montalvão
ID: 40368605
Convert a SQL statement? Or do you mean convert data from a column?
0
 

Author Comment

by:vbnetcoder
ID: 40368634
I have a date in my database as one format and want it to display in another

MM/DD/YY

TO

YYYY/MM
0
 
LVL 46

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40368646
You can use the CONVERT function.
SELECT CONVERT(VARCHAR(12),ColNameHere,111) --> Returns yyyy/mm/dd
SELECT CONVERT(VARCHAR(7),ColNameHere,111) --> Returns yyyy/mm

Open in new window

0
 

Author Closing Comment

by:vbnetcoder
ID: 40399180
ty
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now