Reputation: 15
I have an assignment to change the existing date format in an existing T-SQL view statement. Where the date format is set to YYYY-MM-DD 00:00:00.000
the task is to change is to ALTER VIEW to MM-DD-YY
formatting. I'm lost on this one.
USE Ch8_simpleco
ALTER VIEW
AS invoice
SELECT INV_DATE
SET INV_DATE (MMDDYY)
FROM dbo.v_cust_invoices;
Upvotes: 0
Views: 2034
Reputation: 41
You can use FORMAT() like this:
ALTER VIEW invoice
AS
SELECT FROMAT(INV_DATE,'MM-dd-yy') as INV_DATE
FROM dbo.v_cust_invoices
Upvotes: 0
Reputation: 82524
You are probably looking for something like this:
ALTER VIEW invoice
AS
SELECT COVERT(char(8), INV_DATE, 10) -- will get you dd-MM-yy (no century!)
FROM dbo.v_cust_invoices
Upvotes: 1