Calculating Day & Hour

Hi,

I have two date filed called date1 & date2

wherein user enters any date in “Date1” and enters only time “in Date2” field ( properties set by custom in property box)

i have again Date3 field where user can enter date, and only timing in “Date4” as above said

Well, let me make you understable where i need help.

Now if in “Date1” field if they enters 23/01/2009 & 15:00 hrs in “Date2” and in Date 3 they enters 24/01/2009 & 20:00 hrs in Date4" so how can now the hours difference comes total 29 hours .

in another computed text field it would display as 1 day 5 hours !!

this would be vary upon valued entered in respective date and time field

can anybody have any idea on this…

dev

Subject: Calculating Day & Hour

Hi,

@If(!@IsTime(Date1) | !@IsTime(Date2) | !@IsTime(Date3) | !@IsTime(Date4); @Return(“”); “”);

vardate1:=@Date( @year(Date1) ; @month(Date1) ; @day(Date1) ; @hour(date2) ; @minute(date2) ; @second(date2) );

vardate2:=@Date( @year(Date3) ; @month(Date3) ; @day(Date3) ; @hour(date4) ; @minute(date4) ; @second(date4) );

noHours:=(vardate2 - vardate1) / 3600;

@Text( @Integer (noHours/24)) + " d " + @Text(@Modulo(noHours; 24)) + " h"

You have to add some validations.

Konrad

Subject: RE: Calculating Day & Hour

Thanks Konrad,

but it gives an error

“Incorrect data type for operator or @Function: Time/Date expectedDaysIncorrect data type for operator or @Function: Time/Date expectedHour(s)”

" i have put following formula .

Validate1:=@Date(@Year(DStartDate_1);@Month(DStartDate_1);@Day(DStartDate);@Hour(DStartTime_1);@Minute(DStartTime_1);@Second(DStartTime_1));

Validate2:=@Date(@Year(DEndDate_1);@Month(DEndDate_1);@Day(DEndDate);@Hour(DEndTime_1);@Minute(DEndTime_1);@Second(DEndTime_1));

nHours:=(Validate1-Validate2)/3600;

@Text(@Integer(nHours/24))+ “Days”+@Text(@Modulo(nHours;24)) +“Hour(s)”

“ON TEXT WITH COMPUTED FIELD”

DEV

Subject: RE: Calculating Day & Hour

  1. You missed first line of my code. Why?2. I told you about some validation you have to do.

Konrad

Subject: RE: Calculating Day & Hour

Yes Konrad, i did that what you told !

even though when i am entring date & time value it gives the same error !

i dont understand you for what do you mean by validation !?

Subject: RE: Calculating Day & Hour

Hi,

By validation I mean:

  • checking if all field are filled with date/time value (your error message says that no all date and time fields are filled)

  • checkin if date3 ia after date1

  • if time difference is less that 1 day then you can hide day part in your result

  • and so on…

Konrad

Subject: RE: Calculating Day & Hour

Hi Konard,

You are awesome … thanks a lot…

i gone through it & got desire result…thank you once again.

Dev