Change date format in SQL Server

I'm currently creating a warehouse stock management for my company and upon the data structure for the date, it automatically sets to (year-month-day) as a default format and I would like to change the format to MM/DD/YYYY specification.

However, I have checked the conversion format but it did not specify how to convert the entire column data into a specific format. Only show today's date with a format in which I intended to convert.

Is there any simple conversion to this problem without having to recreate the table again?

enter image description here

Table Schema

Upvotes: 0

Views: 2673

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 520898

You should store the stock date as a bona fide date or datetime column in SQL Server. Then, if you want to view that date a certain way, e.g. as MM/DD/YYYY, use the CONVERT function for that. For example:

SELECT
    GETDATE() AS date_orig,                          -- 2020-09-23 03:45:06.343
    CONVERT(varchar, GETDATE(), 101) AS date_new;    -- 09/23/2020

Upvotes: 2

Related Questions