Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2010
    Posts
    2

    Unanswered: Creating A Time Duration Field

    So I've created a database for the Call of Duty: Modern Warfare 2 game for the XBox 360, as well as one for Call of Duty: Black Ops. I'm basically keeping track of my performance on XBox Live with variables such as which map each round was played on, which weapons I've used, attachments, kills & deaths, etc... I'm a nerd, obsessed with data and statistics. lol

    One of the fields I'm having trouble with is the duration of each match. I want to have the user input the length of each match in the form of MM:SS, but I don't want it associated with an actual clock time. Just 5 minutes and 45 seconds, for example.

    I had resorted to using a simple Integer data type, but I have to convert the time into total seconds prior to entering the data, and that's kind of a hassle. Is there a data type I can use which can represent minutes and seconds without a clock time being implied?

    Any help would be greatly appreciated. This is quite frustrating.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    use an INTEGER for total seconds

    yeah, it's a hassle, innit

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Nov 2010
    Posts
    2
    I suppose I might be able to make two separate fields; one for minutes and one for seconds. The "minutes" field could be multiplied by 60 to give me the number of seconds, then be added to the "seconds" field.

    I was really hoping there was another method for doing this. I've come up empty handed in every instance.

    This also seems like a problem someone would run into if they were, say, a runner and wanted to keep track of lap times. You can't just input an elapsed amount of time without it being attached to a system time from which you must do arithmetic. I'm really surprised that this issue hasn't been addressed, especially in such versatile software as SQL Server.
    Last edited by MrSkeptical; 11-17-10 at 09:29.

  4. #4
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    In Oracle you have INTERVAL data type. Unfortunately, SQL Server has not.
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

Tags for this Thread

Posting Permissions

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