Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    134

    Unanswered: Date as part of primary key?

    I have three items which make up the primary key:
    ProjectNumber, Hardware, Date

    Problem: The Date is formatted with date and time, how can I add a record and use just the date?

    Currently I use GetDate() in my stored proc.

    Mike B

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Dates are not stored in any particular format. They are stored as a numeric value that indicates the number of days elapsed from a baseline date and the number of seconds elapsed since midnight (the decimal portion).

    If you only want to store the whole-date portion, then instead of storing getdate store the results of this expression:

    convert(char(10), getdate(), 120)

    This will yield a time value equal to midnight. It's up to your interface to determine how the value is displayed.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Feb 2004
    Posts
    134
    Quote Originally Posted by blindman
    Dates are not stored in any particular format. They are stored as a numeric value that indicates the number of days elapsed from a baseline date and the number of seconds elapsed since midnight (the decimal portion).

    If you only want to store the whole-date portion, then instead of storing getdate store the results of this expression:

    convert(char(10), getdate(), 120)

    This will yield a time value equal to midnight. It's up to your interface to determine how the value is displayed.
    Exactly what I wanted, thank you!

    Mike B

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •