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 databaseanyone can help? tnx
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 databaseanyone can help? tnx
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.
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..
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..
Output is still in HOURS.. wala pa ko down to SECONDS nga computation, ako pa gisuwayan..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"); } }
Last edited by stealthghost; 09-14-2012 at 01:58 PM.
already got it bro. ok na. pero post lng imo codes basin mas dali imo. tnx
HI! You could use MySQL ADDTIME in the query
Similar Threads |
|