How to format datetime as mm/dd/yyyy

Need to format data in a view to display as mm/dd/yyyy instead of the default the datetime format of yyyy/mm/dd. Convert?

SELECT        [ZSOFU5080VA07 VBAK-VBELN], [PART NUMBER], [ZSOFU5080VA07 MARA-MFRNR], CAST([SALES ORDER DATE] AS DATETIME) AS [SALES ORDER DATE], DIVISION, 
                         [ZSOFU5080VA07 VBAK-AUART], QUANTITY, [ZSOFU5080VA07 VBAP-POSNR], PLANT, [CUST. PO NUMBER], [STORAGE LOCATION], [REQUESTED DELIVERY DATE], 
                         [PRICE EACH], [PROFIT CENTER], [ZSOFU5080VA07 VBAP-PRCTR], [TOTAL PRICE], [CUSTOMER NUMBER], COUNTRY, [CUSTOMER NAME], [CONTACT INFO], CITY, 
                         [ZIP CODE], STATE, ADDRESS, [ZSOFU5080VA07 MAKT-MATNR], DESCRIPTION, [ZSOFU5080VA07 VBRP-VBELN], [ZSOFU5080VA07 VBRP-POSNR], [QTY INVOICED], 
                         INVOICED, [TOTAL COST], MARGIN, [ZSOFU5080VA07 VBRP-FKLMG], [ZSOFU5080VA07 LIPS-VBELN], [DATE CREATED], [ESTIMATED DELIVERY DATE], 
                         [GOODS ISSUE DATE]
FROM            dbo.ZSOFUVA5SALES_table

Open in new window

maximus1974Asked:
Who is Participating?
 
zephyr_hex (Megan)Connect With a Mentor DeveloperCommented:
For example:
SELECT CONVERT(VARCHAR(10),[Sales Order Date], 101)

Open in new window

0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
A buffet of date formats is in Paul Maxwell's article SQL Server Date Styles (formats) using CONVERT()

>Need to format data in a view to display as mm/dd/yyyy instead of ... yyyy/mm/dd
For presentation purposes --> SELECT convert(varchar, GETDATE() ,101)
0
 
zephyr_hex (Megan)DeveloperCommented:
DECLARE @test DATE = '2016-08-02'
SELECT CONVERT(VARCHAR(10),@test, 101)

Open in new window


returns:
08/02/2016
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
(typo fix in my original post, after looking at zephyr_rex's comment)
101 instead of 1, as the 100 means include the first two characters that represent the century.
0
 
maximus1974Author Commented:
Yes, for presentation purposes, thank you. Using SELECT convert(varchar, GETDATE() ,1) , how does the statement know what field to format?
0
 
Jim HornConnect With a Mentor Microsoft SQL Server Developer, Architect, and AuthorCommented:
The use of GETDATE() was for illustration only, something you can copy/paste into SSMS, execute, and verify that it works.  Replace the GETDATE() with the column name you wish to use, everywhere you wish to do this, in the SELECT clause of your query.  

There's a wompload of columns in the query you posted, so I didn't want to assume.
0
All Courses

From novice to tech pro — start learning today.