how to hndle month

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mak1084
    New Member
    • Jul 2007
    • 44

    how to hndle month

    hello friends i'm creting databas in SQL server..
    in this data base i have to store only month and year not date then which data type i use for this...


    thanks
  • allik7
    New Member
    • Feb 2008
    • 10

    #2
    Originally posted by mak1084
    hello friends i'm creting databas in SQL server..
    in this data base i have to store only month and year not date then which data type i use for this...


    thanks
    Why not use datatype char/varchar

    Comment

    • mak1084
      New Member
      • Jul 2007
      • 44

      #3
      Originally posted by allik7
      Why not use datatype char/varchar
      to do a validation i thik it will be better..in case a user enters a wrong month or year..

      Comment

      • Delerna
        Recognized Expert Top Contributor
        • Jan 2008
        • 1134

        #4
        I doubt there is a date data type that has only month and year
        You will need to use a char/varchar/int and perform your validation at the front end

        Comment

        • ck9663
          Recognized Expert Specialist
          • Jun 2007
          • 2878

          #5
          though it's always recommended to do the validation in the front-end as a part of your apps, it's also recommended to protect the table from invalid data that did not pass through the apps (sql analyzer - insert, etc...)...use CONSTRAINT or TRIGGER depending on your requirement...

          -- ck

          Comment

          • jimmylee
            New Member
            • Feb 2008
            • 17

            #6
            hey friend,

            pls use varchar datatype.

            Comment

            • amitpatel66
              Recognized Expert Top Contributor
              • Mar 2007
              • 2358

              #7
              Originally posted by mak1084
              hello friends i'm creting databas in SQL server..
              in this data base i have to store only month and year not date then which data type i use for this...


              thanks

              Use VARCHAR datatype ans store the date value in MMYYYY format.
              In front end app where you do validation, fetch first two characters for month and last four for years and validate. I hopw this helps!!

              Comment

              • mak1084
                New Member
                • Jul 2007
                • 44

                #8
                hey thanks every one.. you guys helped me a lot.

                Comment

                Working...