How to get calculat total number of hours using two variable (login date time and logout date time ) the first variable sort in an entity when user login and the variable sort in the same entity when user logout date time
Hi Andrew,
You want to know the duration in hours of the user between the time he logs in and logs out, is that it?
To calculate the number of hours between two date times, you can use the OutSystems built-in function DiffHours, example below:
Regarding the login date time and logout date time, the first one is saved and handled automatically on the platform, on the attribute Last_Login from the table User (from System):
Nonetheless, the logout date time is not saved by default, so you would have to have to create a table to store this information. You could create for instance a table User_Extended with the UserId and LastLogoutDate to be filled when the user presses logout. After having the logout and login, you can easily get the hours difference using the DiffHours function mentioned above.
Hope it helps.
Regards,João
how i can save the total value in an entity
You will have to create a attribute for ex. "TotalHours" in a entity, for saving the Total hours. You can create it in User_Extended entity mentioned by João above. Then in Login action or which ever action you plan to add this logic you can add it there. You will have to fetch the Last_login from User entity and LastLogoutDate from User_Extended entity and use them in DiffHours(Last_login ,LastLogoutDate). Then save this value into "TotalHours" of User_Extended entity.
Hope that helps you.
How I can assign date tmie 1 and date time 2
how i can create sql code to add the total value of attendance in an entity
hi Andrew,
The Last_login attribute which you will fetch from User entity assign it to DateTime1. The LastLogoutDate attribute which you will fetch from User_Extended entity assign it to DateTime2. Then use it DiffHours(DateTime1,DateTime2)
The propose solution works... but needs that the user make logout for register the hours.
What can we do for the situation that the session finish without user intervention ?
Best regards