Ask the Expert

'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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: