Best MySQL date/time data type when using Ruby?

Discussion in 'Ruby' started by John N Joyner, Jul 11, 2007.

  1. In the years when I used PHP to develop web apps, I found either a MySQL
    TIMESTAMP or an integer of the same value was most convenient for
    storing date/time information and then converting back and forth using
    PHP functions.

    Now that I'm using Ruby, I'm wondering whether the MySQL DATETIME type
    might be a better match with the Ruby Date class and its methods, based
    on looking at the Date class documentation. I'd be interested to know
    whether Rubyists who use MySQL mostly use the DATETIME data type or the
    TIMESTAMP data type? (I'm not using ROR, though I have nothing against
    it.)

    Any input much appreciated.
    --
    John N Joyner
    Ruby, MySQL, Pair Networks
    John N Joyner, Jul 11, 2007
    #1
    1. Advertising

  2. John N Joyner

    John Joyce Guest

    On Jul 10, 2007, at 8:36 PM, John N Joyner wrote:

    > In the years when I used PHP to develop web apps, I found either a
    > MySQL
    > TIMESTAMP or an integer of the same value was most convenient for
    > storing date/time information and then converting back and forth using
    > PHP functions.
    >
    > Now that I'm using Ruby, I'm wondering whether the MySQL DATETIME type
    > might be a better match with the Ruby Date class and its methods,
    > based
    > on looking at the Date class documentation. I'd be interested to know
    > whether Rubyists who use MySQL mostly use the DATETIME data type or
    > the
    > TIMESTAMP data type? (I'm not using ROR, though I have nothing against
    > it.)
    >
    > Any input much appreciated.
    > --
    > John N Joyner
    > Ruby, MySQL, Pair Networks
    >


    You don't need to use Rails to use its database ORM component
    ActiveRecord. ActiveRecord doesn't do the timestamp mysql type really
    the way you would expect (AFAIK). It instead chooses to simple store
    a datetime and let you manage that date data in Ruby code instead.

    If you choose to use Ruby DBI gem, it is more what you might be used
    to with PHP or Perl more direct SQL stuff.

    Either approach works pretty well in Ruby, since the Ruby classes
    Time and Date have a lot of nice functionality built in.
    John Joyce, Jul 11, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Buchan
    Replies:
    2
    Views:
    725
    Kevin Buchan
    Dec 1, 2003
  2. Chris Berg
    Replies:
    0
    Views:
    788
    Chris Berg
    Oct 27, 2003
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,250
    Michael Borgwardt
    May 30, 2004
  4. Yong Wang

    Python MySQL API and date data type

    Yong Wang, Aug 26, 2004, in forum: Python
    Replies:
    1
    Views:
    564
    Dennis Lee Bieber
    Aug 27, 2004
  5. Keith Cochrane
    Replies:
    2
    Views:
    612
    Keith Cochrane
    Aug 6, 2006
Loading...

Share This Page