Date and Calendar Analytics
Date Calculation.

functions for calendar date calculations. More...

Functions

int __stdcall SFDB_EDATE (LONG argDate, LPCTSTR szPeriod, PLONG retVal)
 computed the date after a given a period (e.g. 1w, 1m, 3w, etc.)
 
int __stdcall SFDB_NWKDAY (WORD weekdy, short order, WORD mnth, WORD year, PLONG retVal)
 Returns the serial number of the n-th weekday in a month.
 
int __stdcall SFDB_WKDYOrder (LONG argDate, short *retVal)
 Returns the order of the weekday in the month for a given date. This is the inverse operator of SFDB_NWKDAY().
 
int __stdcall SFDB_WEEKDAY (LONG argDate, WORD argReturnType, LPWORD retVal)
 Returns the day of the week corresponding to a date. The day is given as an integer, ranging from 1 (Sunday) to 7 (Saturday), by default..
 
int __stdcall SFDB_DTADJUST (LONG argDate, WORD argNextPrev, LPCTSTR holidays, LPLONG zDates, size_t nSize, WORD nWkndNo, LPLONG retVal)
 Examines whether the given date falls on a weekend or a holiday (i.e. non-working day), and returns the nearest working business day using a Business Day Convention (BDC).
 
int __stdcall SFDB_ISWRKDY (LONG argDate, LPCTSTR holidays, LPLONG zDates, size_t nSize, WORD nWkndNo)
 Examines a given date for weekends and holidays (non-working days), and returns FALSE if it falls on a non-working day; otherwise it returns TRUE.
 
int __stdcall SFDB_NETWRKDYS (LONG argStartDate, LONG argEndDate, LPCTSTR holidays, LPLONG zDates, size_t nSize, WORD nWkndNo, int *retVal)
 Returns the number of whole working days between two dates (inclusive). Working days exclude weekends and any date identified as a holiday.
 
int __stdcall SFDB_WORKDAY (LONG argDate, short nDays, LPCTSTR holidays, LPLONG zDates, size_t nSize, WORD nWkndNo, LPLONG retVal)
 Returns the serial date number that represents the date that falls after the start date by a given number of working days.
 

Detailed Description

Function Documentation

◆ SFDB_DTADJUST()

int __stdcall SFDB_DTADJUST ( LONG argDate,
WORD argNextPrev,
LPCTSTR holidays,
LPLONG zDates,
size_t nSize,
WORD nWkndNo,
LPLONG retVal )
Parameters
[in]argDate(Required) The serial date number that represents the given date
[in]argNextPrev(Required) the Business Day Convention (BDC): 1=Following, 2=Following Modified, 3=Preceding, 4=Preceding Modified, 5=Unadjusted (default).
[in]holidays(Optional) A (:_:) separated list of holiday names, calendars, countries or currency.
[in]zDates(Optional) An array of holidays dates; each expressed as a serial number (i.e. number of days since 1.1.1970)
[in]nSize(Required) The number of dates in zDates.
[in]nWkndNo(Optional) is the weekend number (1-7,11-17). If 0, the western weekend (i.e. 1, "Saturday, Sunday") is used.
[out]retVal(Required) The functions returns the date of the nearest business day.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDerror
See also
SFDB_ISWRKDY()

calculate the date of the next (or previous) period using a day-counting convention to handle dates that fall on weekend and holidays.

Remarks
Example
Requirements
Target Platform Windows
Header SFDBM.h (include Windows.h)
Library SFDBM.lib
DLL SFDBM.dll

◆ SFDB_EDATE()

int __stdcall SFDB_EDATE ( LONG argDate,
LPCTSTR szPeriod,
PLONG retVal )
Parameters
[in]argDate(Required) Is the base filename of the database file
[in]szPeriod(Optional) Is the description of a period range (e.g. "5-days", "1 month", "1m", "3 w", "-1 year").
[out]retVal(Required) is the calculated date that falls after the given period.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDerror
See also
SFDB_DTADJUST

advance the date by the given period and return that date

Remarks
Example
Requirements
Target Platform Windows
Header SFDBM.h (include Windows.h)
Library SFDBM.lib
DLL SFDBM.dll
Since
v1.68

◆ SFDB_ISWRKDY()

int __stdcall SFDB_ISWRKDY ( LONG argDate,
LPCTSTR holidays,
LPLONG zDates,
size_t nSize,
WORD nWkndNo )
Parameters
[in]argDate(Required) The serial date number that represents the given date
[in]holidays(Optional) A (:_:) separated list of holiday names, calendars, countries or currency.
[in]zDates(Optional) An array of holidays dates; each expressed as a serial number (i.e. number of days since 1.1.1970)
[in]nSize(Required) The number of dates in zDates.
[in]nWkndNo(Optional) is the weekend number (1-7,11-17). If 0, the western weekend (i.e. 1, "Saturday, Sunday") is used.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDerror
See also
SFDB_DTADJUST()

examine whetehr a give data is a workday or not.

Remarks
Example
Requirements
Target Platform Windows
Header SFDBM.h (include Windows.h)
Library SFDBM.lib
DLL SFDBM.dll

◆ SFDB_NETWRKDYS()

int __stdcall SFDB_NETWRKDYS ( LONG argStartDate,
LONG argEndDate,
LPCTSTR holidays,
LPLONG zDates,
size_t nSize,
WORD nWkndNo,
int * retVal )
Parameters
[in]argStartDate(Required) a serial date number that represents start date.
[in]argEndDate(Required) a serial date number that represents finish date.
[in]holidays(Optional) A (:_:) separated list of holiday names, calendars, countries or currency.
[in]zDates(Optional) An array of holidays dates; each expressed as a serial number (i.e. number of days since 1.1.1970)
[in]nSize(Required) The number of dates in zDates.
[in]nWkndNo(Optional) is the weekend number (1-7,11-17). If 0, the western weekend (i.e. 1, "Saturday, Sunday") is used.
[out]retVal(Required) The functions returns the number of work days in the given period.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDerror
See also
SFDB_ISWRKDY()
Remarks
Example
Requirements
Target Platform Windows
Header SFDBM.h (include Windows.h)
Library SFDBM.lib
DLL SFDBM.dll

◆ SFDB_NWKDAY()

int __stdcall SFDB_NWKDAY ( WORD weekdy,
short order,
WORD mnth,
WORD year,
PLONG retVal )
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Parameters
[in]weekdy(Required) A weekday (i.e. 1=Sunday, 2=Monday, 3=Tuesday, ..., 7=Saturday)
[in]order(Required) the n-th occurence in the month (i.e. 1=First, 2=Second, 3=Third, 4=Fourth and -1=Last).
[in]mnth(Required) the month in the year expressed as a number (i.e. 1=Jan, 2=Feb, ..., 12=Dec).
[in]year(Required) the target year (2 or 4 digits) (e.g. 99, 2007, 2008, 09, etc.).
[out]retVal(Required) The functions return the calculated serial number of the n-th weekday in a month/year.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDerror
See also
FDB_WKDYOrder()

return the date of the n-th weekday in a given month and year.

Remarks
Example
Requirements
Target Platform Windows
Header SFDBM.h (include Windows.h)
Library SFDBM.lib
DLL SFDBM.dll

◆ SFDB_WEEKDAY()

int __stdcall SFDB_WEEKDAY ( LONG argDate,
WORD argReturnType,
LPWORD retVal )
Parameters
[in]argDate(Required) The serial date number that represents the given date
[in]argReturnType(Required) a number that designates the weekdays coding (or ordering) scheme. If missing, convention=1 (Sun=1,..,Sat=7) is assumed.
[out]retVal(Required) The functions returns the day of the week corresponding to a date
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDerror
See also
SFDB_NWKDAY()

return the numeric representation of the weekday for a given convention

Remarks
Example
Requirements
Target Platform Windows
Header SFDBM.h (include Windows.h)
Library SFDBM.lib
DLL SFDBM.dll

◆ SFDB_WKDYOrder()

int __stdcall SFDB_WKDYOrder ( LONG argDate,
short * retVal )
Parameters
[in]argDate(Required) The serial date number that represents the given date
[out]retVal(Required) The functions returns the order of the weekday in the month for a given date.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDerror
See also
SFDB_NWKDAY()

return the order of the weekday of a given date in that month.

Remarks
Example
Requirements
Target Platform Windows
Header SFDBM.h (include Windows.h)
Library SFDBM.lib
DLL SFDBM.dll

◆ SFDB_WORKDAY()

int __stdcall SFDB_WORKDAY ( LONG argDate,
short nDays,
LPCTSTR holidays,
LPLONG zDates,
size_t nSize,
WORD nWkndNo,
LPLONG retVal )
Parameters
[in]argDate(Required) The serial date number that represents the given date
[in]nDays(Required) A number of workdays to advance
[in]holidays(Optional) A (:_:) separated list of holiday names, calendars, countries or currency.
[in]zDates(Optional) An array of holidays dates; each expressed as a serial number (i.e. number of days since 1.1.1970)
[in]nSize(Required) The number of dates in zDates.
[in]nWkndNo(Optional) is the weekend number (1-7,11-17). If 0, the western weekend (i.e. 1, "Saturday, Sunday") is used.
[out]retVal(Required) The functions returns the serial date number after a given number of working days.
Returns
status code of the function call: zero = success, positive = success with a warning, and negative = error occurred.
Return values
NDK_SUCCESSsuccess
NDK_FAILEDerror
See also
SFDB_ISWRKDY()
Remarks
Example
Requirements
Target Platform Windows
Header SFDBM.h (include Windows.h)
Library SFDBM.lib
DLL SFDBM.dll