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
Medium Priority
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?
Question by:vbnetcoder
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
  • 2
  • 2
LVL 66

Expert Comment

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

Expert Comment

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

Author Comment

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



LVL 51

Accepted Solution

Vitor Montalvão earned 2000 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


Author Closing Comment

ID: 40399180

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

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.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

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