+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18

Thread: TIMEDIFF issue

  1. #1
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,763
    Blog Entries
    2
    Rep Power
    8

    TIMEDIFF issue

    Hi
    I have a field (Search_Time) which stores "minute" in integer.
    Now i have to find timediff using that "minute". like
    Code:
    Select * From tblmessage Where timeDIFF(now(), Message_Time) <= Search_Time
    
    If i hard code time, like this, then it works fine
    Code:
    Select * From tblmessage Where timeDIFF(now(), Message_Time) <= '00:15:00'
    
    Now the problem is that if say the Search_Time field has value above 60, then this query doesnt work.

    Do i have to convert minutes in integer to something like hh:mm:ss, if yes, how??

    MySql 4.1
    VB.NET 2.0

    Micky

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #3
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,763
    Blog Entries
    2
    Rep Power
    8

    Quote Originally Posted by jmurrayhead View Post
    Thanx J, let me try and be back

  4. #4
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,763
    Blog Entries
    2
    Rep Power
    8

    Nopes J
    It takes a datetime value in STR_TO_DATE(str, format)

    But i have an integer.

  5. #5
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,763
    Blog Entries
    2
    Rep Power
    8

    I got it
    Code:
    Select * From tblmessage Where timeDIFF(now(), Message_Time) <= CONCAT(Search_Time / 60, ':', Search_Time - (Search_Time / 60), ':00')
    
    Thanx to sync_or_swim at other place

  6. #6
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  7. #7
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,763
    Blog Entries
    2
    Rep Power
    8

    Just for the records, in MySql 5.1, its quite easy
    Code:
    Select * From tblmessage Where TIMESTAMPDIFF(minute, Message_Time, now()) <= Search_Time 

  8. #8
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,763
    Blog Entries
    2
    Rep Power
    8

    Quote Originally Posted by jmurrayhead View Post
    J, that converts seconds, but i have minutes

  9. #9
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by micky View Post
    J, that converts seconds, but i have minutes
    lol well, there's also MAKETIME(): MySQL :: MySQL 5.1 Reference Manual :: 11.6 Date and Time Functions

    I know one of these functions is going to work...much shorter than typing out S_O_S's solution
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  10. #10
    Lazy Bum micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky is a jewel in the rough micky's Avatar
    Join Date
    Jul 2008
    Location
    India
    Posts
    1,763
    Blog Entries
    2
    Rep Power
    8

    Quote Originally Posted by jmurrayhead View Post
    lol well, there's also MAKETIME(): MySQL :: MySQL 5.1 Reference Manual :: 11.6 Date and Time Functions

    I know one of these functions is going to work...much shorter than typing out S_O_S's solution
    I have tried that too J, infact from this page i have tried almost everything

    and you know what, SOS solution isnt correct either

    I hate MySql

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. PC Internet issue
    By Rebelle in forum Microsoft Windows
    Replies: 40
    Last Post: May 15th, 2009, 10:43 AM
  2. php.ini and mssql_connect issue
    By dr_rock in forum PHP Development
    Replies: 0
    Last Post: March 2nd, 2009, 09:11 PM
  3. display issue
    By todd2006 in forum ASP Development
    Replies: 4
    Last Post: January 23rd, 2009, 05:55 PM
  4. Issue with ampersand &amp;
    By Rebelle in forum ASP Development
    Replies: 3
    Last Post: April 17th, 2008, 11:54 AM

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

SEO by vBSEO