Results 1 to 2 of 2

Thread: Mysql-Datetime addition help

  1. #1
    Join Date
    May 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Mysql-Datetime addition help

    Hi,
    I have a table tableA with fields id,item,sent_to,date_posted (datetime), delivery_hrs(int(2))

    date_posted is time at which record is inserted into table, delivery_hrs in hrs (int)

    Here I want records whose date_posted when added to delivery_hrs results in date lesser than or equal to current date and time.
    eg
    If date_posted = '2010-01-13 02:30:00', delivery_hrs = 2, current datetime = '2010-01-13 05:30:00'
    then delivery_time = date_posted + delivery_hrs i,e '2010-01-13 04:30:00'
    which is lesser than current datetime = '2010-01-13 05:30:00'.

    What will be the sql for this??

    Thanks in advance!!
    Regards

  2. #2
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default

    Quote Originally Posted by php_techy View Post
    Hi,
    I have a table tableA with fields id,item,sent_to,date_posted (datetime), delivery_hrs(int(2))

    date_posted is time at which record is inserted into table, delivery_hrs in hrs (int)

    Here I want records whose date_posted when added to delivery_hrs results in date lesser than or equal to current date and time.
    eg
    If date_posted = '2010-01-13 02:30:00', delivery_hrs = 2, current datetime = '2010-01-13 05:30:00'
    then delivery_time = date_posted + delivery_hrs i,e '2010-01-13 04:30:00'
    which is lesser than current datetime = '2010-01-13 05:30:00'.

    What will be the sql for this??

    Thanks in advance!!
    Regards
    use the int data type instead of date time to store dates....

    then calculate the values by dividing i.e.
    int date is saved as a seconds, to get the day value divide it by
    ( 60*60*24)

Bookmarks

Posting Permissions

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