Search code examples
sql-servert-sqlviewalter

Alter view sql date


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;

Solution

  • 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