276
Views
8
Comments
Solved
Calculate total number of hours

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

2018-10-29 08-31-03
João Marques
 
MVP
Solution

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

2021-01-05 18-22-18
andrew mahfouz

how i can save the total value in an entity


UserImage.jpg
Shilpa Uppund


Hi Andrew,

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 "TotalHoursof User_Extended entity.

Hope that helps you.

2021-01-05 18-22-18
andrew mahfouz

How I can assign date tmie 1 and date time 2

2021-01-05 18-22-18
andrew mahfouz


how i can create sql code to add the total value of attendance in an entity

1.PNG
UserImage.jpg
Shilpa Uppund
Solution

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)


2021-01-05 18-22-18
andrew mahfouz

how i can create sql code to add the total value of attendance in an entity

Imprnant.PNG
2018-10-29 08-31-03
João Marques
 
MVP
Solution

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

2021-01-05 18-22-18
andrew mahfouz

how i can save the total value in an entity


UserImage.jpg
Shilpa Uppund


Hi Andrew,

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 "TotalHoursof User_Extended entity.

Hope that helps you.

2021-01-05 18-22-18
andrew mahfouz

How I can assign date tmie 1 and date time 2

2021-01-05 18-22-18
andrew mahfouz


how i can create sql code to add the total value of attendance in an entity

1.PNG
UserImage.jpg
Shilpa Uppund
Solution

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)


2021-01-05 18-22-18
andrew mahfouz

how i can create sql code to add the total value of attendance in an entity

Imprnant.PNG
2014-10-21 20-15-17
Alberto Ferreira

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.