4est
4est

Reputation: 3168

Set up date format during creating table

I create column as below:

ReportingPeriod DATETIME

Now I noticed that it has format:

yyyy-mm-dd hh:mm:ss[.fff]    
2016-03-11 00:00:00.000

It's possible to set up format as "DD/MM/YYYY" during creating table? something as:

ReportingPeriod DATETIME format("DD/MM/YYYY")

Upvotes: 0

Views: 6181

Answers (1)

S M
S M

Reputation: 3233

You can use

ReportingPeriod DATETIME CONVERT(VARCHAR(10), ReportingPeriod , 103)  

But as suggested by Tim Schmelter in comments, Don't mix up the value of a datetime with a formatted datetime which is always a string. Convert them when you want to display them.

Means

`SELECT CONVERT(VARCHAR(10), ReportingPeriod , 103) AS [DD/MM/YYYY]` From *yourTable*

Sample Output

19/02/1972

Upvotes: 2

Related Questions