Foramatting a date column in table creation.

  • I am trying to get my feet underneath me in SQL Server after working with Oracle for a few years. I have a question I need help with. I am trying to create a table that has some date columns. I want to format the date columns to accept a specific date format for example YYYYDDMM. Is that possible? If so, how is it done? Any help will be greatly appreciated.

    Thanks,

    M. Hussain

  • Date columns should use one of the available date data types (date, datetime, datetime2, etc). Those data types don't care about format. Different formats for input and display can be used with CONVERT() among the format styles accepted. As a best practice, I suggest the use of ISO format YYYYMMDD to avoid confusions.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply