Subtracting date fields in lotus notes
I need to subtract two date fields in order to get the number of days as the difference. I tried subtracting them in the "Default Value" section of the Field. But the message Incorrect Data Type for operator or @function appears on the screen.
The field was defined as an editable/number field.
Can you please advice on how to properly solve this problem using the @function in the "default value" section of the field property?
Thank you for kind help.
You can find the number of seconds between two dates by subtracting them. Then get the days by dividing by 86400 (seconds in a day). No @function is required.
I tried to simulate your problem, and I think I know what your issue is. In fact you almost have it working. Use this formula in the computed "DaysElapsed" field.
@If(@IsTime(Date1) & @IsTime(Date2);(Date2-date1)/86400;0);
If the date fields are blank whilst in edit mode, the calculation will fail because a blank value is not a "date", they are blank values which cannot have mathematical functions performed on them. So, a bit of type checking should fix it. I have used a default of zero whilst the values cannot be calculated.
精彩评论