Hello,

i want to calcul the diffence betwenn two date :

date A :12/01/2012 08:36:00

date B 14/01/2012 11:25:00


i want to find 2 day 2hours and 49 minutes.


what can i do?


When i want to calculate 2 hours i have 3049 minute is it 51 hourss it is 48 hours ( 2 days) and 3 hours (it would be 2)


Hi Damien,


You have a few Build-in functions that you could use to achieve this. You can find them in the expression editor.



I hope this helps you.


Regards,


Bart


I think but when i use it wont work like i explain


my code is

DiffDays(GetCRSSChronologieById.List.Current.CRSSChronologie.DateHeureReprise,GetCRSSChronologieById.List.Current.CRSSChronologie.DateHeureFin)
 +" jours "+
TextToInteger(((DiffHours
(GetCRSSChronologieById.List.Current.CRSSChronologie.DateHeureReprise,GetCRSSChronologieById.List.Current.CRSSChronologie.DateHeureFin))))
 + ":" +
Mod(DiffMinutes
(GetCRSSChronologieById.List.Current.CRSSChronologie.DateHeureReprise,GetCRSSChronologieById.List.Current.CRSSChronologie.DateHeureFin),60)

Hi Damien,

Look this component, maybe help you:

https://www.outsystems.com/forge/component-overview/8734/gettimediffrenceindays-hours-min-secs 


You can download and see how is built.

Example:

Regards.

Hello.

The most straightforward approach is to create a new Date (start at 0 years, 0 months, 0 days, 0 hours, 0 minutes, and 0 seconds) and add to it the difference in seconds between the two dates.

AddSeconds( NullDate() , DiffSeconds(DateA, DateB) )

It works for up to 60 years.

In your case it would return 1900-01-03 02:49:00 (2 days, 2 hours, 49 minutes and 0 seconds after 1900-01-01)

To save in distinct variables, you have to do it one by one like explained above.

Solution

Hi Damian,

As the Agno's solution suggested, you have to get the difference in the minimal unity you need, and then convert to other unities.


For example, if you have to show a hour and minute format, you have to get the difference in minutes using DiffMinutes() and then see how many full hours and remaining minutes you have in this value.

e.g: if you have 130 minutes returned in DiffMinutes() you would have 2 full hours and 10 minutes remaining.


The same thing can be done for seconds.

If you have to show a hour, minute and second format. You have to get the difference in seconds using DiffSeconds() and then see how many full hours, full minutes and remaining seconds you have in this value.


This calc can be achieve using the example Agno posted.



Also the solution Nuno pointed, is a way of doing it, however it will return a DateTime as result, with a given day, month and year.


Cheers :)


RR

Solution

thanks all

Damien Larzabal wrote:

thanks all

 

 I'm glad I could help


:D