how can save current time in database attribute?

seenunandagiri

New Member
Hi,

I am building an employee appication where I need to capture the employee login time...when I am trying with the following code it doesn't work. Can u help me in this problem.

CREATE InOut.
assign empNum=integer(getSession("empNum")) inoutTime=DATETIME(STRING(TIME,"MM-DD-YYYY HH:MM:SS")) .
 
Hi friends,

I need your help in modifying my code for build employee time sheet.

create pay.inout .
assign inout.inoutTime=NOW .

when I use the above code the time is saved into the inout attribute. I need such code where employee login time should be constant for the whole day. when I try to use the above code It changes when i refresh the page.
so, please help me in "how to get first login time of an employee" ?
 
What you need to do is to find the first InOut record for that user, sorted in inoutTime order, assuming that the user logs in after midnight and logs out before midnight. If the user is on shifts then you need some fancier programming.

If you have a date field for InOut it might make things easier, depending on what you are trying to achieve.
 
You say it should be constant for the whole day. Do you mean day or session? If session, then you might consider a superprocedure or singleton object to record the first time when the session starts and provide it for all later requests. If day, then you need to use the database and, basically look up today's record and, if it isn't there, then create it.
 
Hi Tamhas,

I need employee time details per session. whenever user login into the system he need to start entering times and when logout that values should be vanished. help me in writing such type of code.
 
It's hard to say what you should do -- so far you have provided only a very narrow and fragmentary view of your requirements.

But one thing that stands out to me is that you might want to step back and re-think your db design. Redundantly recording start time seems like a bad idea to me. I'd probably use a design more like:

Code:
sessionId  eventId    eventDateTime
=========  ========   ================
    1      login      Nov 12 2008 8:00:00
    1      taskXbegin Nov 12 2008 8:01:00
    1      taskXend   Nov 12 2008 9:05:00
    1      taskYbegin Nov 12 2008 9:05:00
    1      taskYend   Nov 12 2008 9:30:00
...
    1      logout     Nov 12 2008 17:00:00

You could argue that the taskXend note is not needed if there is always a taskYstart at the same time -- but that would depend on how your business operates and i don't know that.
 
Actually, the old Varnet logging looked a lot like this and the end task was useful since having it missing was a good sign of an aborted run. Plus, there could be time between end and start when the user was at the menu.
 
Back
Top