Q
Problem solve Get help with specific problems with your technologies, process and projects.

# '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

#### Have a question for an expert?

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

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

#### Start the conversation

Send me notifications when other members comment.

## SearchWindowsServer

• ### What's new with the Exchange hybrid configuration wizard?

The Exchange configuration wizard continues to evolve into a refined utility with enhanced capabilities that administrators ...

• ### Top Office 365 MFA considerations for administrators

A complex password only goes so far to stop a breach. Implementing multifactor authorization can help, but make sure the product ...

• ### October Patch Tuesday resolves 59 vulnerabilities

Microsoft attempts to stamp out printing issues that originated from a faulty out-of-band patch for an Internet Explorer zero-day.

## 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 ...

## SearchDataCenter

• ### Improve server rack physical security with ISO standards

Safeguarding information access is essential to data center operations. With ISO Standard 27001 and the right locking mechanisms,...

• ### Essential private cloud migration steps

Executive buy-in, application evaluation and tool configuration are all important parts of cloud selection. With these steps, ...

• ### IBM quantum computers' usefulness in sight -- using binoculars

IBM's Bob Sutor discusses Big Blue's new quantum systems and computation center, the realities of quantum computing today and how...

## SearchContentManagement

• ### WebPurify launches profanity filter for memes and images

WebPurify has launched a beta of its Optical Character Recognition Profanity Filter Service to identify and block profane images ...

• ### Digital asset management benefits the future of work

Digital asset management promises to transform digital work, making it easier to tag documents, analyze video and provide image ...

• ### Box cloud content management adds PDF tools, boosts security

Box partners with Adobe in releasing a new set of PDF tools that can be used within Box's content management cloud to enable ...

Close