Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Member inthezone's Avatar
    Join Date
    Sep 2002
    Posts
    59
    Member #
    192
    When creating a DB which notation would you give to time fields used to track the difference between two dates (for a "__ days since user X registered" feature)? Would you just call it "TEXT" like you do for an HTML field, or is there some other attribute you give to it?
    The Extent of my PHP Knowledge:

    <?php
    print "In the Zone";
    ?>

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    I wouldn't do it at all and just do it dynamically in PHP. But if I was to use it I would probably use INT or something instead of text (it could store the difference in seconds as an INT).
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Member inthezone's Avatar
    Join Date
    Sep 2002
    Posts
    59
    Member #
    192
    Originally posted by filburt1
    I wouldn't do it at all and just do it dynamically in PHP. But if I was to use it I would probably use INT or something instead of text (it could store the difference in seconds as an INT).
    Actually I would need a vast amount of these time differences. The app I'm trying to make is a management system of when I mail something (such as mail-in offers or rebates) and when I receive whatever I'm sending away for, just as a semi-practical use of a database to get me more affluent with MySQL. It wouldn't need to be a dynamic to-the-second time but rather something like Sent: 5/15/02; Received: 5/29/02; Time: 14 days. Would PHP or INT be pertinent given what I'm attempting to do?
    The Extent of my PHP Knowledge:

    <?php
    print "In the Zone";
    ?>

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Both would work. I suppose it's a matter of which you like better:

    1. PHP-way: slower, easier to understand, doesn't require extra db space
    2. MySQL: stores redundant data, faster (effectively a cache), requires an extra column in the db

    If the two dates are only dates (i.e., no times, just m/d/y) then int would be fine; it could be the difference in days.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Member inthezone's Avatar
    Join Date
    Sep 2002
    Posts
    59
    Member #
    192
    Would I have to add an extra field in the DB for the time difference?
    The Extent of my PHP Knowledge:

    <?php
    print "In the Zone";
    ?>

  7. #6
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Yup, that's one of the disadvantages, you create data redundancy.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  8. #7
    Member inthezone's Avatar
    Join Date
    Sep 2002
    Posts
    59
    Member #
    192
    How about using 2 DATE fields along with a strototime function?
    The Extent of my PHP Knowledge:

    <?php
    print "In the Zone";
    ?>


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:28 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com