Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 105
  • Last Modified:

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

What is the best way to convert a  sql statement from one format to another? What function should i use?
0
vbnetcoder
Asked:
vbnetcoder
  • 2
  • 2
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Depends.  Define 'one format' and 'another'.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Convert a SQL statement? Or do you mean convert data from a column?
0
 
vbnetcoderAuthor Commented:
I have a date in my database as one format and want it to display in another

MM/DD/YY

TO

YYYY/MM
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
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
 
vbnetcoderAuthor Commented:
ty
0

Featured Post

Technology Partners: 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!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now