187
Views
4
Comments
Solved
Sql
Question

 How do you calculate the difference between logging in and logging out using Sql

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

Hi Andrew,


On your aggregate, you can add a new attribute (using the New attribute button) and make use of OutSystems built-in functions DiffDays, DiffHours, DiffMinutes or DiffSeconds to get the difference between two date times. Something like in the example below where I use the DiffHours function:


 

Hope it helps.


Regards,
João

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

Great, but I need  function calculat different between date time 1 and date tmie 2 using sql queries 

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

Hi Andrew,


In Advanced SQL, the syntax varies if you're using SQL Server, MySQL or Oracle.

For instance, if you're using SQL Server, the syntax is DATEDIFF( date_part , start_date , end_date) where the date_part defines if you're looking for the difference in days, minutes, etc.

For instance,


SELECT DATEDIFF(hh, {User_Extendend}.[LoginStartDate], {User_Extended}.[LoginEndDate]) FROM {User_Extended} would give you the difference in hours.


Here you can find examples and the possible values for the date_part.


Regards,

João

2021-01-05 18-22-18
andrew mahfouz
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.