Results 1 to 8 of 8
  1. #1
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465

    Default how to calculate subtract logout time in login time. java


    mga boss usaon nako pag.deduct for example login time is 9:30AM and logout time is 5:00 pm,
    usaon nako pag.calculate sa time in between the two hours? liboga oe. ako pa ning i.chop2x? para sa database anyone can help? tnx

  2. #2

    Default Re: how to calculate subtract logout time in login time. java

    Sulayi DateDiff function brod.

    DateDiff( interval, date1, date2)

    Sa imo case;
    DateDiff("h", Login, Logout)

    Icheck lang kung pareha ra syntax sa java, vbscript man gud ako gamit karon.

  3. #3

    Default Re: how to calculate subtract logout time in login time. java

    TS ingon ako migo.. daghan ra man sa google mga example about dateUtils mo computer sa difference duha..
    ingon pud sya no need na e save ang difference instead pwede ang time in or timeout ra..

  4. #4
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465

    Default Re: how to calculate subtract logout time in login time. java

    Quote Originally Posted by gwenharold View Post
    TS ingon ako migo.. daghan ra man sa google mga example about dateUtils mo computer sa difference duha..
    ingon pud sya no need na e save ang difference instead pwede ang time in or timeout ra..
    dghan btaw bro pero puro sad pangutana wai saktong tubag.
    need calculate interval jud para mahibaw.an pilay bayad.

  5. #5

    Default Re: how to calculate subtract logout time in login time. java

    Quote Originally Posted by jairoh_ View Post
    dghan btaw bro pero puro sad pangutana wai saktong tubag.
    need calculate interval jud para mahibaw.an pilay bayad.
    nangita pa ko bro.. medyo busy man gud.. nangita ko sa Date og Calendar nga mga functions.. wa pa ko naka tiwas og testing..

    tagaan nya tika kung maka kita na ko..

    Code:
    import java.util.Calendar;
    
    
    public class Main {
    
    
      public static void main(String[] args) {
    
        //Get Instances of Calendar to get System Date
        Calendar timeIn = Calendar.getInstance();
        Calendar timeOut = Calendar.getInstance();
        
        //Variables for HOUR IN (for manual input of time in)
        int hourIn = 8, minIn = 30, secIn = 15;
    
        //Variables for HOUR OUT (for manual input of time out)
        int hourOut = 17, minOut = 5, secOut = 35;
        
        //Setting time in
        timeIn.set(timeIn.get(Calendar.YEAR), timeIn.get(Calendar.MONTH), timeIn.get(Calendar.DATE), hourIn, minIn, secIn);
    
        //Setting time out
        timeOut.set(timeOut.get(Calendar.YEAR), timeOut.get(Calendar.MONTH), timeOut.get(Calendar.DATE), hourOut, minOut, secOut);
        
        //Show the Time IN and TIME OUT
        System.out.println("Time In: "+timeIn.getTime());
        System.out.println("Time Out: "+timeOut.getTime());
        
        //Experiment as seen in this link -> java - Compare hours and minutes - Stack Overflow
        long hours = timeOut.getTimeInMillis()-timeIn.getTimeInMillis();
        hours = hours/(1000 * 60 * 60);
    
        System.out.println(hours+" hours of work");
    
      }
    }
    Output is still in HOURS.. wala pa ko down to SECONDS nga computation, ako pa gisuwayan..
    Last edited by stealthghost; 09-14-2012 at 01:58 PM.

  6. #6
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465

    Default Re: how to calculate subtract logout time in login time. java

    already got it bro. ok na. pero post lng imo codes basin mas dali imo. tnx

  7. #7

    Default Re: how to calculate subtract logout time in login time. java

    Quote Originally Posted by jairoh_ View Post
    already got it bro. ok na. pero post lng imo codes basin mas dali imo. tnx
    Nice ka bro! maayu na jud ka Java.. hehehe..

    wala kaayu ko time mag program karon adlawa, ako lang nya tiwasun next time. hehehe..

  8. #8

    Default Re: how to calculate subtract logout time in login time. java

    HI! You could use MySQL ADDTIME in the query

  9.    Advertisement

Similar Threads

 
  1. How to open MS Office 2007 in MS Office 2003?
    By junmar4 in forum Software & Games (Old)
    Replies: 12
    Last Post: 02-09-2007, 11:09 AM
  2. LF: Who knows how to run Fallout 1&2 in WinXP
    By Hitchiker in forum Software & Games (Old)
    Replies: 2
    Last Post: 10-18-2006, 09:57 AM
  3. How to post a picture here in istorya?
    By virgoboy in forum Support Center
    Replies: 1
    Last Post: 07-19-2006, 11:14 PM
  4. how to landscape mode sa N70 in taking pics?
    By baboy in forum Gizmos & Gadgets (Old)
    Replies: 0
    Last Post: 03-11-2006, 04:48 PM
  5. How to become a local band in cebu
    By outline in forum Music & Radio
    Replies: 14
    Last Post: 02-07-2006, 03:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top