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

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 50

Accepted Solution

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


Author Closing Comment

ID: 40399180

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

707 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