Understanding the DATEDIF Function and Its Parameters with an Example

Understanding the DATEDIF Function and Its Parameters with an Example

book

Article ID: KB0070117

calendar_today

Updated On:

Products Versions
ibi WebFOCUS All

Description

Understanding the DATEDIF function and its parameters with a sample focexec

DAYS_DIFF/I9 = DATEDIF(RT_LOAN_ENTRY_DATE,TODAY1,'WD');

If the field RT_LOAN_ENTRY_DATE has a value of 2024/08/1, then DAYS_DIFF will have a value of 56 days.  How is the value 56 calculated?

Issue/Introduction

Understanding the DATEDIF Function and Its Parameters with an Example

Environment

All

Resolution

Resolution :
The third parameter in the DATEDIF function is WD which means "Weekdays".
Weekday (WD) : With the weekday unit, DATEDIF does not count Saturday or Sunday when calculating days. This means that the difference between Friday and Monday is one day.
 
DATEDIF function :
The DATEDIF function returns the difference between two full component standard dates in units of a specified component.

Syntax: How to Find the Difference Between Two Dates
   DATEDIF(from_date, to_date, 'component')

from_date : Is the start date from which to calculate the difference. It is a full component date.
to_date Date : Is the end date from which to calculate the difference.

Component can be any one of the following: 
Alphanumeric : (Is one of the following enclosed in single quotation marks: )
Y indicates a year unit.
M indicates a month unit.
D indicates a day unit.
WD indicates a weekday unit.
BD indicates a business day unit.

In our example -
  • 'RT_LOAN_ENTRY_DATE' is the start date
  • TODAY1 is the end date
  • The function 'WD' calculates the difference in weekdays

Additional Information

Refer the function document to get more details regarding this DATEDIF function Or any component unit. it also includes couple of good examples as well.
https://docs.tibco.com/pub/wf-wf/8207.28.14/doc/pdf/TIB_wfwf_8207.28.0_functions.pdf?id=11 , Page no 380