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
96 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 47

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 47

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

777 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