locked
Create Table RRS feed

  • Question

  • Currently, a client wants my team to create a column in a table that stores the months and dates (e g, 12th 0f April without the year) of births of it customers as many will only give that information and not the year.

    Please help

    Wednesday, October 19, 2011 2:07 PM

Answers

  • Hi,

    you can have two columns, Month and day, and fill them when user gave information. and you can have third column as a calculated or in your view to show date in your format (12th of April).

     


    Regards Ahmad
    Thursday, October 20, 2011 6:01 AM
  • Hi kingdomkev,

    which data type to use and how? 

    Hmmm, I wish all questions I got were this easy! ;)

    For the day: tinyint, of course.
    For the month, either tinyint or varchar(n) (with n depending on the
    longest month name in the language you choose) - or maybe nvarchar(n)
    if you use a language that needs Unicode for its month names.

    For the computed column: Check out "CREATE TABLE' in Books Online to
    find the syntax.


    Hugo Kornelis, SQL Server MVP
    My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
    Thursday, October 20, 2011 1:35 PM
  • Hi Hugo,

    In regards to your answer

    "For the day: tinyint, of course.
    For the month, either tinyint or varchar(n) (with n depending on the
    longest month name in the language you choose) - or maybe nvarchar(n)
    if you use a language that needs Unicode for its month names"

    How would you write the query for BirthMonth to show April or any of the month without showing the  digit i.e. 12? 

    Thanks

    • Marked as answer by kingdomkev Friday, November 11, 2011 10:22 AM
    Thursday, November 10, 2011 10:44 AM

All replies

  • Hi,

    you can have two columns, Month and day, and fill them when user gave information. and you can have third column as a calculated or in your view to show date in your format (12th of April).

     


    Regards Ahmad
    Thursday, October 20, 2011 6:01 AM
  • Hi Ahmend Anbaran,

    Thanks for your respond. which data type to use and how? 

     

    Thanks

    Thursday, October 20, 2011 11:29 AM
  • Hi kingdomkev,

    which data type to use and how? 

    Hmmm, I wish all questions I got were this easy! ;)

    For the day: tinyint, of course.
    For the month, either tinyint or varchar(n) (with n depending on the
    longest month name in the language you choose) - or maybe nvarchar(n)
    if you use a language that needs Unicode for its month names.

    For the computed column: Check out "CREATE TABLE' in Books Online to
    find the syntax.


    Hugo Kornelis, SQL Server MVP
    My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
    Thursday, October 20, 2011 1:35 PM
  • Hello Hugo,

    Thanks a lot for your concern and support..

    Thursday, October 20, 2011 1:57 PM
  • Hi Hugo,

    In regards to your answer

    "For the day: tinyint, of course.
    For the month, either tinyint or varchar(n) (with n depending on the
    longest month name in the language you choose) - or maybe nvarchar(n)
    if you use a language that needs Unicode for its month names"

    How would you write the query for BirthMonth to show April or any of the month without showing the  digit i.e. 12? 

    Thanks

    • Marked as answer by kingdomkev Friday, November 11, 2011 10:22 AM
    Thursday, November 10, 2011 10:44 AM