Q

'Type Mismatch' error when manipulating dates

I have two fields. Field1 is a text field with type computed and Field2 is date type. I have written an agent where I have to subtract these two fields. When I do this I get a error message saying "Type MisMatch." Can you please tell me why this is happening and what the remedy may be? Dates are the hardest thing for me to work with. I usually end up doing a lot of stuff I probably don't have to when I start manipulating dates. So,...

if someone reads this and thinks, "Why is he doing that?" it's just from past experience, and I'm covering all my bases.

Let's say we have two fields, Field1 and Field2 (as in your problem). I'll compute Field1 to "07/24/2002 12:00:00 PM". I'll put in Field2 [07/21/2002 08:34 AM] as a Date/Time field value.

I'll put five more fields below the button (which I labeled "equals"):
- Field3 shows the number of total seconds between the two dates.
- Field4 shows the number of days (within Field3)
- Field5 shows the number of hours
- Field6 shows the number of minutes
- Field7 shows the number of seconds

So, in my example above, I would get 185161 seconds between the two times, which is:

2 Days 3 Hours 26 Minutes 0 Seconds

I'm going to do this in @Function and LotusScript, since you didn't mention which type of agent you were using. First the @Function:

NumDiffSeconds := @TextToTime(Field1) - Field2;
NumDays := NumDiffSeconds / 86400;
NumPartialDays := NumDays - @Integer(NumDays);
NumHours := NumPartialDays * 24;
NumPartialHours := NumHours - @Integer(NumHours);
NumMinutes := NumPartialHours * 60;
NumPartialMinutes := NumMinutes - @Integer(NumMinutes);
NumSeconds := NumPartialMinutes * 60;

FIELD Field3 := NumDiffSeconds;
FIELD Field4 := @Integer(NumDays);
FIELD Field5 := @Integer(NumHours);
FIELD Field6 := @Integer(NumMinutes);
FIELD Field7 := @Integer(NumSeconds);
@True

This was first published in July 2002

Dig deeper on Domino Resources - Part 2

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close