Results 1 to 20 of 20

Thread: Time Difference

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    675

    Time Difference

    Hi

    I have DatetIme field . I want to subtract this field from Current Time & check the difference . I fit is greater than 6 Hrs it should give message.

    Thanks

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,238

    Re: Time Difference

    Last edited by Zvoni; Jan 27th, 2015 at 05:19 AM.
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    675

    Re: Time Difference

    Hi

    I want time difference between current time & database field

    Thanks

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,238

    Re: Time Difference

    And your Problem with my answer is what?
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,959

    Re: Time Difference

    Quote Originally Posted by Jagjit View Post
    Hi

    I want time difference between current time & database field

    Thanks
    So what do you think is the solution to that is? If you want something from a database, you need get the data from the database and stuff it into a variable, yes? Soooooo......

    Quote Originally Posted by Zvoni View Post
    And your Problem with my answer is what?
    You didn't write the code.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,238

    Re: Time Difference

    Quote Originally Posted by techgnome View Post
    You didn't write the code.

    -tg
    How inconsiderate of me......
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    675

    Re: Time Difference

    Hi Zvoni

    I want time difference in Hours

    Thanks

  8. #8
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,893

    Re: Time Difference

    Again, check the DateDiff function in the help!

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    675

    Re: Time Difference

    Hi Arnoudtv/Zvoni

    o.k but if i want that if diff in Hrs is greater than 5 it should give message & it it should display like Hours / Minutes . For ex if diff between 2 times is 2 Hrs & 30 min it should display 2 Hrs And 30 Min.

    Thanks

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,959

    Re: Time Difference

    So use datediff to get the minutes... if it's more than 360, then it's more than 6 hours.... if it's less, it's less than 6 hours. if you then want to break it down, use the diff mod 60 to get the minutes, then use (diff - (diff mod 60)) / 60 to get the hours, format it, and display it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,238

    Re: Time Difference

    tg, that's pure math you're talking about :-)

    It's funny how many people use computers, and don't have a clue about maths, considering the word Computer derives from the latin verb computare (=to calculate).

    Ah well, another mystery of the universe to solve......
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  12. #12
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,451

    Re: Time Difference

    The REAL mystery is why you haven't researched the DateDiff function and posted your attempts at solving your issue.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    675

    Re: Time Difference

    Hi techgnome

    Thanks

  14. #14
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,238

    Re: Time Difference

    Quote Originally Posted by SamOscarBrown View Post
    The REAL mystery is why you haven't researched the DateDiff function and posted your attempts at solving your issue.
    Sam, the funny thing is: You don't even need the DateDiff-Function to solve this problem, considering DateTime is actually a Double-Value (The part left of the decimal representing the day, the part right of the decimal the time).
    But with that we're back at maths, the universal language of the universe

    Anyone here who has a working Star-Trek Universal Translator?
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  15. #15
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,882

    Re: Time Difference

    Wow - I wanted to see what could possibly get up to 14 posts on a simple question of time in VB6.

    I'll never get that 5 minutes back again

    Seriously though - why bring attitude to a knowledge forum?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  16. #16
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,238

    Re: Time Difference

    Quote Originally Posted by szlamany View Post

    Seriously though - why bring attitude to a knowledge forum?
    Because "Knowledge" implies the willingness to learn this "knowledge", and not posting some half-baked questions, where you have to guess 50% of the meaning, and then expecting the code on a silver platter!

    There is a reason the OP has a red reputation.

    He made a statement (not asked a question!), we gave him an answer, that should have gotten him started. and the OP ignored this answer, instead demanding (!) "I want ......"
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  17. #17
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,882

    Re: Time Difference

    Then around post #4 or #5 the OP should have been instructed to post code. Without that code being posted the thread should have died due to the ignoring it should have received.

    As it stands now - this thread offers no code advice - just a link or two. Peppered in all that is repetition and sarcasm.

    If you want to teach people how to ask good questions only answer those people with good questions!

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  18. #18
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,451

    Re: Time Difference

    Uh, which I did at 12 when I first saw this.....(The REAL mystery is why you haven't researched the DateDiff function and posted your attempts at solving your issue.)

  19. #19
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,882

    Re: Time Difference

    Unfortunately by post #12 the thread was pretty much derailed.

    Still waiting to see code - and wondering where does that "database" part come in?

    Since I rely on SQL so much for my business I would have suggested changing the SELECT statement to return a message based on the time comparison - done in the query itself.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  20. #20
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,451

    Re: Time Difference

    Yeah, depending upon final use/display. BUT, OP has been so inconsistent with posts (and ever so sketchy), doubt we will find that out.

Posting Permissions

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



Click Here to Expand Forum to Full Width