BETWEEN() | Проверка значения |
CDOW() | Преобразует значение даты в название дня недели в виде символьной строки. |
CMONTH() | Преобразует дату в название месяца в виде символьной строки. |
CTOD() | Преобразует символьную строку, содержащую дату, в переменную типа DATE. |
DATE() | Возвращает системную дату в виде значения типа DATE. |
DAY() | Возвращает номер дня в виде числа. |
DOW() | Преобразует значение даты в числовое значение дня недели. |
DTOC() | Преобразует значение даты в символьную строку. |
DTOS() | Преобразует значение даты в строку символов формата ггггммдд. |
EMPTY() | Определяет, является ли результат выполнения выражения пустым. |
FT_ACCTADJ() | Adjust beginning or ending fiscal pd. dates to acctg. dates |
FT_ACCTMONTH() | Return accounting month data |
FT_ACCTQTR() | Return accounting quarter data |
FT_ACCTWEEK() | Return accounting week data |
FT_ACCTYEAR() | Return accounting year data |
FT_ADDWKDY() | Return true number of days to add given number of workdays |
FT_CALENDAR() | Display date/time calendar, find a date, return calendar data. |
FT_CIV2MIL() | Convert usual civilian format time to military time. |
FT_DATECNFG() | Set beginning of year/week for FT_ date functions |
FT_DAYOFYR() | Return calendar, fiscal or accounting day data |
FT_DAYTOBOW() | Calculate no. of days between date and beginning of week |
FT_DOY() | Find number of day within year |
FT_EASTER() | Return the date of Easter |
FT_ELAPMIN() | Return difference, in minutes, between two mil format times. |
FT_ELAPSED() | Return elapsed time between two days and/or times |
FT_ELTIME() | Compute difference between times in hours, minutes, seconds. |
FT_FDAY() | Return first day of the month |
FT_LDAY() | Return last day of the month |
FT_MADD() | Add or subtract months to/from a date |
FT_MIL2CIV() | Convert time in military format to civilian format. |
FT_MIL2MIN() | Convert time in military format to number of minute of day. |
FT_MIN2DHM() | Convert numeric minutes to days, hours and minutes. |
FT_MIN2MIL() | Convert minute of day to military format time. |
FT_MONTH() | Return Calendar or Fiscal Month Data |
FT_QTR() | Return Calendar or Fiscal Quarter Data. |
FT_SYS2MIL() | Convert system time to military time format. |
FT_WEEK() | Return calendar or fiscal week data |
FT_WORKDAYS() | Return number of work days between two dates |
FT_WOY() | Find number of week within year |
FT_YEAR() | Return calendar or fiscal year data |
MAX() | Возвращает большее из двух чисел или дат. |
MIN() | Возвращает меньшее из двух чисел или значения дат. |
MONTH() | Определяет по значению даты номер месяца. |
QOUT() | Выводит список выражений на консоль. |
SECONDS() | Возвращает количество секунд, прошедших с полуночи. |
SLEEP() | Остановить выполнение программы на заданное количество секунд и(или) милисекунд. |
TIME() | Возвращает системное время. |
TRANSFORM() | Преобразует заданное выражение в форматированную строку символов. |
TYPE() | Определяет тип выражения. |
VALTYPE() | Определяет тип данных выражения. |
YEAR() | Преобразует значение даты в номер года в числовом виде. |
CDOW(<выражение типа дата>) --> название дня недели
CDOW() возвращает название дня недели в виде символьной строки. Первая буква - заглавная ( в верхнем регистре ), остальные - строчные (в нижнем регистре). Для нулевой даты CDOW() возвращает пустую строку ("").
CDOW() - это функция преобразования, которая используется для форматированной выдачи даты в отчеты, метки и на экран.
Следующий пример показывает работу CDOW(): ? DATE() // Результат: 09/01/90 ? CDOW(DATE()) // Результат: Пятница ? CDOW(DATE() + 7) // Результат: Пятница ? CDOW(CTOD("06/12/90")) // Результат: Понедельник
CMONTH(<дата>) --> название месяца
CMONTH() возвращает название месяца по заданной дате в виде строки символов. Первый символ названия месяца - заглавный (в верхнем регистре), остальные - строчные ( в нижнем регистре ). Для нулевой даты CMONTH() возвращает пустую строку ("").
CMONTH() - функция преобразования дат, которая предназначена для создания форматированных дат, представленных в виде символьных строк, для отчетов, меток, при выдаче на экран.
Следующий пример иллюстрирует работу функции CMONTH(): ? CMONTH( DATE() // Результат: Сентябрь ? CMONTH( DATE() + 45) // Результат: Октябрь ? SUBSTR( CMONTH( DATE()), 1, 3) +; STR( DAY( DATE())) // Результат: Сен 29
CTOD(<строка-дата>) --> дата
<строка-дата> | - строка символов, состоящая из чисел, представляющих |
собой номер месяца, дня и года, разделенные любым символом, кроме | |
цифр. День, месяц и год должны быть заданы в соответствии с | |
установленным командой SET DATE форматом. Если не задано число, | |
определяющее век, оно определяется установкой команды SET EPOCH. |
CTOD() возвращает значение даты. Если <строка-дата> задана некорректно, CTOD() возвращает пустую дату.
CTOD() - это функция преобразования символьных строк, которая преобразует строку символов в дату. Для формирования пустой даты необходимо задать <строка-дата> либо в виде строки нулевой длины (""), либо строкой SPACE(8), либо строкой "//".
CTOD() используется везде, где необходима дата в виде литеральной строки. Например:
При инициализации переменной для хранения дат
При определении литеральной строки, содержащей дату как аргумента предложения RANGE команды @...GET
При определении литеральной строки, содержащей дату, для выполнения арифметических действий над ней
При сравнении результата выполнения выражения над датами с литеральной строкой
При присваивании значения литеральной строки полю типа дата
Функция CTOD() обратна по действию функции DTOC(), которая преобразует значение переменной типа дата в литеральную строку в формате, определенном командами SET DATE и SET CENTURY. DTOC() также преобразует значение переменной типа дата в строку символов в формате ггггммдд.
В этом примере функция CTOD() используется для инициализации двух переменных типа дата, включенных одна в команду GET, а другая - в предложение RANGE: SET CENTURY ON dBegin = CTOD("01-26-1876") dCurrent = CTOD("") @ 10, 10 SAY "Введите дату:" GET dCurrent RANGE dBegin, DATE() READ Этот пример использует CTOD() для преобразования даты в значение типа дата при проверке условия в команде FOR: USE Inventory NEW REPLACE ALL Inventory->Price WITH Inventory->Price * 1.1; FOR Inventory->InvDate < CTOD("10/10/90")
DATE() --> системная дата
No arguments
DATE() возвращает системную дату в виде значения типа DATE.
DATE() - функция получения дат, которая дает возможность устанавливать начальные значения переменных памяти в виде текущей даты, сравнивать другие даты с текущей датой, производить арифметические вычисления над датами с участием текущей даты. Формат вывода даты на дисплей устанавливается командой SET DATE.
Формат, установленный по умолчанию мм/дд/гг.
В следующем примере показано использование функции DATE(): ? DATE() // Результат: 09/01/90 ? DATE() + 30 // Результат: 10/01/90 ? DATE() - 30 // Результат: 08/02/90 dDate = DATE() ? CMONTH(dDate) // Результат: Сентябрь
DAY(<дата>) --> номер дня
DAY() возвращает целое число в пределах от нуля до 31. Если заданный месяц - февраль, предполагается високосный год. Если аргумент имеет значение 29 февраля и год не високосный, DAY() возвращает 0. Если аргумент пустой, DAY() возвращает 0.
DAY() - функция преобразования даты, которая используется для преобразования значения даты в номер дня в месяце. Она используется в комбинации с функциями CMONTH() и YEAR() для форматирования дат, а также при различных вычислениях над датами.
Следующие примеры показывают работу функции DAY() с различными аргументами: ? DATE() // Результат: 09/01/90 ? DAY(DATE()) // Результат: 1 ? DAY(DATE()) + 1 // Результат: 2 ? DAY(CTOD("")) // Результат: 0 Этот пример использует DAY() в комбинации с YEAR() для форматирования значения даты: ? CMONTH(DATE()) + STR(DAY(DATE())) +; "," + STR(YEAR(DATE())) // Результат: Июнь 15, 1990
DOW(<дата>) --> номер дня
DOW() возвращает номер дня недели в виде числа в пределах от одного до семи. Первый день недели - это воскресенье, последний - суббота. Если <дата> имеет пустое значение, DOW() возвращает нуль.
DOW() - это функция преобразования даты, которая преобразует значение даты в число, идентифицирующее день недели. Функция полезна при выполнении расчетов над днями недели. Функция DOW() похожа на функцию CDOW(), которая возвращает день недели в виде строки символов вместо числа.
Следующие примеры показывают работу функций CDOW() и DOW(): ? DATE() // Результат: 09/01/89 ? DOW(DATE()) // Результат: 3 ? CDOW(DATE()) // Результат: Вторник ? DOW(DATE() - 2) // Результат: 1 ? CDOW(DATE() - 2) // Результат: Воскресенье В этом примере показана функция пользователя, которая использует DOW() для расчета даты последнего понедельника от любой другой даты: FUNCTION LastMonday( dDate ) RETURN (dDate - DOW(dDate) + 2)
DTOC(<дата>) --> строка-дата
DTOC() возвращает дату, представленную в виде строки символов. Возвращаемое значение форматируется с учетом установленного текущего формата даты. По умолчанию принимается формат мм/дд/гг. Нулевая дата преобразуется в строку пробелов, равную длине, принятой для формата даты.
DTOC() - функция преобразования даты, которая используется, когда нужно выделить дату в формате, установленном командой SET DATE в качестве элемента символьного выражения (например, при выводе меток). Если требуется специальный формат даты, вы можете использовать функцию TRANSFORM() или соответствующее выражение. Если вы включаете дату как элемент символьного выражения в индекс, для преобразования даты необходимо использовать DTOS() вместо DTOC().
Следующие примеры показывают применение функции DTOC(): ? DATE() // Результат: 09/01/90 ? DTOC(DATE()) // Результат: 09/01/90 ? "Сегодня " + DTOC(DATE()) // Результат: Сегодня 09/01/90
DTOS(<дата>) --> строка-дата
DTOS() возвращает строку длиной в 5 символов в формате ггггммдд. Если значение аргумента <дата> имеет нулевое значение, (CTOD("")), DTOS() возвращает строку из восьми пробелов. Формат возвращаемой строки не зависит от текущей установки формата командой SET DATE.
DTOS() - это функция преобразования даты, которая используется при создании выражений индексов, содержащих значения даты, в строку символов, которая может быть сцеплена с какими-либо другими символьными выражениями. Структура возвращаемого значения - всегда ггггммдд.
Следующие примеры показывают использование функции DTOS() в сочетании с другими функциями: ? DATE() // Результат: 09/01/90 ? DTOS(DATE()) // Результат: 19900901 ? LEN(DTOS(CTOD(""))) // Результат: 8 Этот пример демонстрирует, как создать с использованием DTOS() индекс, включающий в себя комбинацию даты и символьного ключа: USE Sales NEW INDEX ON DTOS(Date) + Salesman TO DateName
FT_ACCTADJ( [ <dGivenDate> ], [ <lIsEnd> ] ) -> dDate
An adjusted date dependent upon mode and work week start day.
Called by other FT_ACCT.. functions. The algorithm is:
Beginning of period mode:
If dGivenDate is in last 3 days of work week Return next week's start date Else Return this week's start date Endif
End of period mode:
If dGivenDate is in last 4 days of work week Return this week's end date Else Return prior week's end date Endif
Beginning of period mode (lIsEnd == .F.) dDate := Ctod( "01/31/91" ) // In last 3 days of work week ? FT_ACCTADJ( dDate ) // 02/03/91 (next week's start) dDate := Ctod( "03/31/91" ) // Not in last 3 days of work week ? FT_ACCTADJ( dDate ) // 03/31/91 (this week's start) End of period mode (lIsEnd == .T.) dDate := Ctod( "01/31/91" ) // In last 4 days of work week ? FT_ACCTADJ( dDate, .T. ) // 02/02/91 (this week's end) dDate := Ctod( "03/31/91" ) // Not in last 4 days of work week ? FT_ACCTADJ( dDate, .T. ) // 03/30/91 (prior week's end)
FT_ACCTMONTH( [ <dGivenDate> ], [ <nMonthNum> ] ) -> aDateInfo
A three element array containing the following data:
aDateInfo[1] - The year and month as a character string "YYYYMM" aDateInfo[2] - The beginning date of the accounting month aDateInfo[3] - The ending date of the accounting month
FT_ACCTMONTH() creates an array containing data about the accounting month containing the given date.
An accounting period has the following characteristics:
If the first week of the period contains 4 or more 'work' days, it is included in the period; otherwise, the first week was included in the prior period.
If the last week of the period contains 4 or more 'work' days it is included in the period; otherwise, the last week is included in the next period. This results in 13 week 'quarters' and 4 or 5 week 'months'. Every 5 or 6 years, a 'quarter' will contain 14 weeks and the year will contain 53 weeks.
// get info about accounting month containing 9/15/90 aDateInfo := FT_ACCTMONTH( Ctod("09/15/90") ) ? aDateInfo[1] // 199009 (9th month) ? aDateInfo[2] // 09/02/90 beginning of month 9 ? aDateInfo[3] // 09/29/90 end of month 9 // get info about accounting month 5 in year containing 9/15/90 aDateInfo := FT_ACCTMONTH( Ctod("09/15/90"), 5 ) ? aDateInfo[1] // 199005 ? aDateInfo[2] // 04/29/89 beginning of month 5 ? aDateInfo[3] // 06/02/90 end of month 5
FT_ACCTQTR( [ <dGivenDate> ], [ <nQtrNum> ] ) -> aDateinfo
A three element array containing the following data:
aDateInfo[1] - The year and qtr. as a character string "YYYYQQ" aDateInfo[2] - The beginning date of the accounting quarter aDateInfo[3] - The ending date of the accounting quarter
FT_ACCTQTR() creates an array containing data about the accounting quarter containing the given date.
An accounting period has the following characteristics:
If the first week of the period contains 4 or more 'work' days, it is included in the period; otherwise, the first week was included in the prior period.
If the last week of the period contains 4 or more 'work' days it is included in the period; otherwise, the last week is included in the next period. This results in 13 week 'quarters' and 4 or 5 week 'months'. Every 5 or 6 years, a 'quarter' will contain 14 weeks and the year will contain 53 weeks.
// get info about accounting month containing 9/15/90 aDateInfo := FT_ACCTQTR( CTOD("09/15/90") ) ? aDateInfo[1] // 199003 (3rd quarter) ? aDateInfo[2] // 07/01/90 beginning of quarter 3 ? aDateInfo[3] // 09/29/90 end of quarter 3 // get info about accounting qtr. 2 in year containing 9/15/90 aDateInfo := FT_ACCTQTR( CTOD("09/15/90"), 2 ) ? aDateInfo[1] // 199002 ? aDateInfo[2] // 04/01/89 beginning of quarter 2 ? aDateInfo[3] // 06/30/90 end of quarter 2
FT_ACCTWEEK( [ <dGivenDate> ], [ <nWeekNum> ] ) -> aDateInfo
A three element array containing the following data:
aDateInfo[1] - The year and week as a character string "YYYYWW" aDateInfo[2] - The beginning date of the accounting week aDateInfo[3] - The ending date of the accounting week
FT_ACCTWEEK() returns an array containing data about the accounting week containing the given date.
An accounting period has the following characteristics:
If the first week of the period contains 4 or more 'work' days, it is included in the period; otherwise, the first week was included in the prior period.
If the last week of the period contains 4 or more 'work' days it is included in the period; otherwise, the last week is included in the next period. This results in 13 week 'quarters' and 4 or 5 week 'months'. Every 5 or 6 years, a 'quarter' will contain 14 weeks and the year will contain 53 weeks.
// get info about accounting week containing 9/15/90 aDateInfo := FT_ACCTWEEK( CTOD("09/15/90") ) ? aDateInfo[1] // 199037 (37th week) ? aDateInfo[2] // 09/09/90 beginning of week 37 ? aDateInfo[3] // 09/15/90 end of week 37 // get info about accounting week 25 in year containing 9/15/90 aDateInfo := FT_ACCTWEEK( CTOD("09/15/90"), 25 ) ? aDateInfo[1] // 199025 ? aDateInfo[2] // 06/17/89 beginning of week 25 ? aDateInfo[3] // 06/23/90 end of week 25
FT_ACCTYEAR( [ <dGivenDate> ] ) -> aDateInfo
A three element array containing the following data:
aDateInfo[1] - The year as a character string "YYYY" aDateInfo[2] - The beginning date of the accounting year aDateInfo[3] - The ending date of the accounting year
FT_ACCTYEAR() creates an array containing data about the accounting year containing the given date.
An accounting period has the following characteristics:
If the first week of the period contains 4 or more 'work' days, it is included in the period; otherwise, the first week was included in the prior period.
If the last week of the period contains 4 or more 'work' days it is included in the period; otherwise, the last week is included in the next period. This results in 13 week 'quarters' and 4 or 5 week 'months'. Every 5 or 6 years, a 'quarter' will contain 14 weeks and the year will contain 53 weeks.
// get info about accounting year containing 9/15/90 aDateInfo := FT_ACCTYEAR( CTOD("09/15/90") ) ? aDateInfo[1] // 1990 ? aDateInfo[2] // 12/31/89 beginning of year ? aDateInfo[3] // 12/29/90 end of year
FT_ADDWKDY( <dStart>, <nWorkDays> ) -> nTrueDays
<nTrueDays> = Number of actual days to add to <dStart> in order to add the required <nWorkDays>
Let's say you are given the problem:
"All invoices are due 10 working days from the date they are printed. Please display the due date on the invoice."
When is the due date? Assuming you are printing the invoices today, your answer is:
dDueDate := DATE() + ft_addWkDay( DATE(), 10 )
A work day is defined as Monday through Friday. Unfortunately this routine does _not_ account for holidays.
This documentation was written by Glenn Scott so if it's wrong, blame him.
// Postdate 5 working days from the first of January dPost := CTOD("01/01/91") dPost += FT_ADDWKDY( dPost, 5 ) // returns 7 true days ? dPost // 01/08/91
FT_CALENDAR ( [ <nRow> ], [ <nCol> ], [ <cColor> ], [ <lShadow> ] , [ <lShowHelp> ] ) -> aRetVal
<nRow> | is an optional screen row for calendar display, |
default row 1. | |
<nCol> | is an optional screen col for calendar display, |
default col 63. | |
<cColor> | is an optional color string for displayed messages, |
default is bright white text over green background. | |
<lShadow> | is an optional logical variable. If true (.T.), |
it uses FT_SHADOW() to add a transparent shadow | |
to the display, default (.F.). | |
<lShowHelp> | is an optional logical variable. If true, uses |
FT_XBOX to display a four line help message | |
if the F1 key is pressed, default (.F.). | |
aRetVal is an 8 element array containing date, month, day, year, month (in character format), day of the week, julian day and current time.
FT_CALENDAR() simply displays today's date, time and julian day in a two line display with an optional box shadow. Cursor keys may be used to page through the calendar by day, week, month or year increments. Returns an 8 element array of calendar data:
Element Value [1] Date in current date format. [2] Numeric month number. [3] Numeric day number. [4] Numeric year number. [5] Month in character format. [6] Day of the week in character format. [7] Numeric Julian day. [8] Current time in time format.
WARNING: FT_CALENDAR uses FT_SHADOW and FT_XBOX from the Nanforum Toolkit!
LOCAL aRetVal[8] CLS aRetVal := FT_CALENDAR (10,40,'W+/RB',.T.,.T.) ?aRetVal[1] // Result: 04/20/91 ?aRetVal[2] // Result: 4 ?aRetVal[3] // Result: 20 ?aRetVal[4] // Result: 1991 ?aRetVal[5] // Result: April ?aRetVal[6] // Result: Saturday ?aRetVal[7] // Result: 110 ?aRetVal[8] // Result: 12:45:20
FT_CIV2MIL( <cCIVTIME> ) -> cMILTIME
<cMILTIME> character string of form hhmm, where 0<=hh<24.
Converts time from 12-hour civilian format to military.
FT_CIV2MIL( " 5:40 pm" ) -> 1740 FT_CIV2MIL( " 5:40 am" ) -> 0540 FT_CIV2MIL( "12:00 n" ) -> 1200 FT_CIV2MIL( "12:00 m" ) -> 0000 Caution: leading blanks are irrelevant; p,a,n,m must be preceded by one and only one space.
FT_DATECNFG( [ <cFYStart> ], [ <nDow> ] ) -> aDateInfo
<cFYStart> | is a character date string in the user's system date |
format, i.e., the same as the user would enter for CTOD(). If | |
this argument is NIL, the current value is unchanged. | |
Note: The year portion of the date string must be present and | |
be a valid year; however, it has no real meaning. | |
<nDow> | is a number from 1 to 7 (1 = Sunday) indicating the |
desired start of a work week. If this argument is NIL, | |
the current value is unchanged. | |
A 2-element array containing the following information:
aDateInfo[1] - an ANSI date string indicating the beginning date of the year. Only the month and day are meaningful.
aDateInfo[2] - the number of the first day of the week (1 = Sunday)
FT_DATECNFG() is called internally by many of the date functions in the library to determine the beginning of year date and beginning of week day.
The default beginning of the year is January 1st and the default beginning of the week is Sunday (day 1). Either or both of these settings may be changed by calling FT_DATECNFG() with the proper arguments. They will retain their values for the duration of the program or until they are changed again by a subsequent call to FT_DATECNFG().
It is not necessary to call FT_DATECNFG() unless you need to change the defaults.
FT_DATECNFG() affects the following library functions:
FT_WEEK() FT_ACCTWEEK() FT_DAYTOBOW() FT_MONTH() FT_ACCTMONTH() FT_DAYOFYR() FT_QTR() FT_ACCTQTR() FT_ACCTADJ() FT_YEAR() FT_ACCTYEAR()
// Configure library date functions to begin year on // July 1st. FT_DATECNFG("07/01/80") // year is insignificant // Examples of return values: // System date format: American aArray[1] aArray[2] aArray := FT_DATECNFG() // '1980.01.01' 1 (Sun.) aArray := FT_DATECNFG('07/01/80') // '1980.07.01' 1 (Sun.) aArray := FT_DATECNFG('07/01/80', 2) // '1980.07.01' 2 (Mon.) aArray := FT_DATECNFG( , 2 ) // '1980.01.01' 2 (Mon.) // System date format: British aArray := FT_DATECNFG('01/07/80', 2) // '1980.07.01' 2 (Mon.)
FT_DAYOFYR( [ <dGivenDate> ], [ <nDayNum> ], [ <lIsAcct> ] ) -> aDateInfo
<dGivenDate> | is any valid date in any valid format. Defaults |
to current system date if not supplied. | |
<nDayNum> | is a number from 1 to 371, signifying a day of a year. |
Defaults to current day if not supplied. | |
<lIsAcct> | is a logical which specifies the type of year to base |
the return value on: .F. = calendar or fiscal year, | |
.T. = accounting year. |
A three element array containing the following data:
If <nDayNum> is specified:
aDateInfo[1] - The date of the specified day number aDateInfo[2] - The beginning date of the year aDateInfo[3] - The ending date of the year
If <nDayNum> is not specified:
aDateInfo[1] - The year and day as a character string "YYYYDDD" aDateInfo[2] - The beginning date of the year aDateInfo[3] - The ending date of the year
FT_DAYOFYR() returns an array containing data about a day in the calendar or fiscal year containing the given date.
The beginning of year date defaults to January 1st but may be changed with FT_DATECNFG().
aDateInfo := FT_DAYOFYR( CTOD("03/31/91") ) ? aDateInfo[1] // 1991090 (90th day of year 1991) ? aDateInfo[2] // 01/01/91 ? aDateInfo[3] // 12/31/91 aDateInfo := FT_DAYOFYR( , 90 ) // assume current date is 3/31/91 ? aDateInfo[1] // 03/31/91 (90th day of year) ? aDateInfo[2] // 01/01/91 ? aDateInfo[3] // 12/31/91 aDateInfo := FT_DAYOFYR( , 90, .T. ) ? aDateInfo[1] // 03/29/91 (90th day of accounting year) ? aDateInfo[2] // 12/30/90 (1st day of accounting year) ? aDateInfo[3] // 12/28/91 (last day of accounting year)
FT_DAYTOBOW( [ <dGivenDate> ] ) -> nDays
A positive number of days to beginning of week, range 0 to 6.
FT_DAYTOBOW() returns the number of days to the beginning of the week. Normally this will be one less than the value that would be returned by the Clipper function DOW(), unless the day for the beginning of the week has been changed with FT_DATECNFG().
dDate := CTOD( "09/15/90" ) ? DOW( dDate ) // 7 ? CDOW( dDate ) // Saturday ? FT_DAYTOBOW( dDate ) // 6 // change beginning of week to Friday (yeah!) FT_DATECNFG( , 6 ) ? DOW( dDate ) // 7 ? CDOW( dDate ) // Saturday ? FT_DAYTOBOW( dDate ) // 1
FT_DOY( <dDate> ) -> <nResult>
Return numeric position of day within the year. Return NIL if parameter does not conform.
Finds the day number, considering 01/01 as day 1 Handles dates with CENTURY ON|OFF, to allow for 21st century. Date validation must be external to this function.
These code fragments find the day number, given a date. // literal character date dDate := CTOD("01/01/91") nDayNum := FT_DOY(dDate) // result: 1 // presume DOS date to be 01/06/91 nDayNum := FT_DOY(DATE()) // result: 6 // date input cDate := SPACE(8) @ 4,10 get cDate PICT "##/##/##" // input 07/04/91 READ nDayNum := FT_DOY(CTOD(cDate)) // result: 185 // last day of year nDayNum := FT_DOY(CTOD("12/31/91")) // result: 365 For a demonstration of this function, compile and link the program WOY.PRG in the Nanforum Toolkit source code.
FT_EASTER( <xYear> ) -> dEdate
No arguments
The actual date that Easter occurs.
Returns the date of Easter for any year after 1582 up to Clipper's limit which the manual states is 9999, but the Guide agrees with the actual imposed limit of 2999.
This function can be useful in calender type programs that indicate when holidays occur.
dEdate := FT_EASTER( 1990 ) && returns 04/15/1990
FT_ELAPMIN( <cTIME1>, <cTIME2> ) -> nMINUTES
<nMINUTES>
Finds the arithmetic difference between time two times (time 2 - time 1). If time 2 is smaller than time 1, a NEGATIVE value is returned.
FT_ELAPMIN( "1718", "2040" ) -> 322 FT_ELAPMIN( "2040", "1718" ) -> -322
FT_ELAPSED([ <dStart> ], [ <dEnd> ], ; <cTimeStart>, <cTimeEnd>) -> aTimedata
<dStart> | is any valid date in any date format. Defaults to DATE(). |
<dEnd> | is any valid date in any date format. Defaults to DATE(). |
<cTimeStart> | is a valid Time string of the format 'hh:mm:ss' where |
hh is hours in 24-hour format. | |
<cTimeEnd> | is a valid Time string of the format 'hh:mm:ss' where |
hh is hours in 24-hour format. |
A two-dimensional array containing elapsed time data.
FT_ELAPSED() calculates the elapsed time between two Date/Time events.
It returns an array which contains the following data:
aRetVal[1,1] Integer Days aRetVal[1,2] Total Days (nn.nnnn) aRetVal[2,1] Integer Hours aRetVal[2,2] Total Hours (nn.nnnn) aRetVal[3,1] Integer Minutes aRetVal[3,2] Total Minutes (nn.nnnn) aRetVal[4,1] Integer Seconds aRetVal[4,2] Total Seconds (nn)
FT_ELAPSED(CTOD('11/28/90'), CTOD('11/30/90'), '08:00:00', '12:10:30') will return: aRetVal[1,1] -> 2 (Days) aRetVal[1,2] -> 2.1740 Days aRetVal[2,1] -> 4 (Hours) aRetVal[2,2] -> 52.1750 Hours aRetVal[3,1] -> 10 (Minutes) aRetVal[3,2] -> 3130.5000 Minutes aRetVal[4,1] -> 30 (Seconds) aRetVal[4,2] -> 187830 Seconds
FT_ELTIME( <cTime1>, <cTime2> ) -> cDiff
<cDiff> character string representing time difference in hh:mm:ss format.
Return the absolute difference between two times in hh:mm:ss format in character hours, minutes and seconds (hh:mm:ss).
FT_ELTIME( "22:40:12", "23:55:17" ) -> 01:15:05 FT_ELTIME( "23:55:17", "22:40:12" ) -> 01:15:05
FT_FDAY( [ <dDateToChk> ] ) -> dFirstDay
A Clipper date value representing the first date of the month.
This function will return the first day of the month of the date passed, or the first day of the current month if no argument is supplied.
dDate := CTOD( "09/15/90" ) ? FT_FDAY( dDate ) // 09/01/90 ? FT_FDAY() // 03/01/91 (current month)
FT_LDAY( [ <dDateToChk> ] ) -> dLastDay
A Clipper date value representing the last date of the month.
This function will return the last day of the month of the date passed, or the last day of the current month if no argument is supplied.
dDate := CTOD( "09/15/90" ) ? FT_LDAY( dDate ) // 09/30/90 ? FT_LDAY() // 03/31/91 (current month)
FT_MADD( [ <dGivenDate> ], [ <nAddMonths> ], [ <lMakeEOM> ] ) -> dDate
<dGivenDate> | is any valid date in any date format. Defaults to |
current system date if not supplied. | |
<nAddMonths> | is the number of months to be added or subtracted. |
Defaults to 0 if not supplied. | |
<lMakeEOM> | is a logical variable indicating whether or not to |
force the returned date to the last date of the month. It only | |
affects the returned date if <dGivenDate> is an end-of-month date. |
A date.
FT_MADD() adds or subtracts months to/from a given date.
If MakeEOM is passed and dGivenDate is the last day of a month, it will return the EOM of calculated month. Otherwise it will return the same day as the day of the passed date.
dDate := CTOD( "09/15/90" ) ? FT_MADD( dDate, 1 ) // 10/15/90 ? FT_MADD( dDate, -2 ) // 07/15/90 // force EOM dDate := CTOD( "04/30/91" ) ? FT_MADD( dDate, 1 ) // 05/30/91 ? FT_MADD( dDate, 1, .T. ) // 05/31/91 <- forced EOM ? FT_MADD( dDate, 2 ) // 06/30/91 ? FT_MADD( dDate, 2, .T. ) // 06/30/91 <- June only has 30 days ? FT_MADD( dDate, 3 ) // 07/30/91 ? FT_MADD( dDate, 3, .T. ) // 07/31/91 <- forced EOM
FT_MIL2CIV( <cCIVTIME> ) -> dMILTIME
<cCIVTIME> character string of form hh:mm (am,pm,n or m), where 0<hh<12.
Converts time from military to civilian format
FT_MIL2CIV( "1640" ) -> 4:40 pm FT_MIL2CIV( "0440" ) -> 4:40 am FT_MIL2CIV( "1200" ) -> 12:00 n FT_MIL2CIV( "0000" ) and FT_MIL2CIV( "2400" ) -> 12:00 m Caution: leading blanks are irrelevant.
FT_MIL2MIN( <cMILTIME> ) -> nMINUTE
<nMINOFDAY> numeric value representing minute of day.
Converts time in military format to number of minute of the day.
FT_MIL2MIN( "1729" ) -> 1049
FT_MIN2DHM( <nMinutes> ) -> aDHM_
<aDHM_> where: aDHM_[1] = cDAYS, aDHM_[2] = cHours, aDHM_[3] = cMinutes
Converts numeric minutes into a character array containing days, hours & minutes.
aDHM_ = MIN2DHM(16789) -> aDHM_[1] = 11, aDHM_[2] = 15, aDHM_[3] = 49
FT_MIN2MIL( <nMINUTE> ) -> cMILTIME
<cMILTIME> character string of form hhmm, where 0<=hh<24.
Converts minute of the day to military format time.
FT_MIN2MIL( 279 ) -> 0439
FT_MONTH( [ <dGivenDate> ], [nMonthNum] ) -> aDateInfo
A three element array containing the following data:
aDateInfo[1] - The year and month as a character string "YYYYMM" aDateInfo[2] - The beginning date of the month aDateInfo[3] - The ending date of the month
FT_MONTH() returns an array containing data about the month containing the given date.
Normally the return data will be based on a year beginning on January 1st with weeks beginning on Sunday.
The beginning of year date and/or beginning of week day can be changed by using FT_DATECNFG(), which will affect all subsequent calls to FT_MONTH() until another call to FT_DATECNFG().
The beginning of year date and beginning of week day may be reset to January 1 and Sunday by calling FT_DATECNFG() with no parameters.
// get info about month containing 9/15/90 aDateInfo := FT_MONTH( CTOD("09/15/90") ) ? aDateInfo[1] // 199009 (9th month) ? aDateInfo[2] // 09/01/90 beginning of month 9 ? aDateInfo[3] // 09/30/90 end of week month 9 // get info about month 5 in year containing 9/15/90 aDateInfo := FT_MONTH( CTOD("09/15/90"), 5 ) ? aDateInfo[1] // 199005 ? aDateInfo[2] // 05/01/90 beginning of month 5 ? aDateInfo[3] // 05/31/90 end of month 5 // get info about month 5 in current year (1991) aDateInfo := FT_MONTH( , 5 ) ? aDateInfo[1] // 199105 ? aDateInfo[2] // 05/01/91 beginning of month 5 ? aDateInfo[3] // 05/31/91 end of month 5
FT_QTR( [ <dGivenDate> ], [ <nQtrNum> ] ) -> aDateInfo
A three element array containing the following data:
aDateInfo[1] - The year and quarter as a character string "YYYYQQ" aDateInfo[2] - The beginning date of the quarter aDateInfo[3] - The ending date of the quarter
FT_QTR() returns an array containing data about the quarter containing the given date.
Normally the return data will be based on a year beginning on January 1st with weeks beginning on Sunday.
The beginning of year date and/or beginning of week day can be changed by using FT_DATECNFG(), which will affect all subsequent calls to FT_QTR() until another call to FT_DATECNFG().
The beginning of year date and beginning of week day may be reset to January 1 and Sunday by calling FT_DATECNFG() with no parameters.
// get info about quarter containing 9/15/90 aDateInfo := FT_QTR( CTOD("09/15/90") ) ? aDateInfo[1] // 199003 (3rd quarter) ? aDateInfo[2] // 07/01/90 beginning of quarter 3 ? aDateInfo[3] // 09/30/90 end of week quarter 3 // get info about quarter 2 in year containing 9/15/90 aDateInfo := FT_QTR( CTOD("09/15/90"), 2 ) ? aDateInfo[1] // 199002 ? aDateInfo[2] // 04/01/90 beginning of quarter 2 ? aDateInfo[3] // 06/30/90 end of quarter 2 // get info about quarter 2 in current year (1991) aDateInfo := FT_QTR( , 2 ) ? aDateInfo[1] // 199102 ? aDateInfo[2] // 04/01/91 beginning of quarter 2 ? aDateInfo[3] // 06/30/91 end of quarter 2
FT_SYS2MIL() -> cMILTIME
No arguments
<cMILTIME> character string of form hhmm, where 0<=hh<24.
Return current system time as character string in military format.
FT_SYS2MIL() -> 1623
FT_WEEK( [ <dGivenDate> ], [ <nWeekNum> ] ) -> aDateinfo
A three element array containing the following data:
aDateInfo[1] - The year and week as a character string "YYYYWW" aDateInfo[2] - The beginning date of the week aDateInfo[3] - The ending date of the week
FT_WEEK() returns an array containing data about the week containing the given date.
Normally the return data will be based on a year beginning on January 1st with weeks beginning on Sunday.
The beginning of year date and/or beginning of week day can be changed by using FT_DATECNFG(), which will affect all subsequent calls to FT_WEEK() until another call to FT_DATECNFG().
The beginning of year date and beginning of week day may be reset to January 1 and Sunday by calling FT_DATECNFG() with no parameters.
// get info about week containing 9/15/90 aDateInfo := FT_WEEK( CTOD("09/15/90") ) ? aDateInfo[1] // 199037 (37th week) ? aDateInfo[2] // 09/09/90 beginning of week 37 ? aDateInfo[3] // 09/15/90 end of week 37 // get info about week 25 in year containing 9/15/90 aDateInfo := FT_WEEK( CTOD("09/15/90"), 25 ) ? aDateInfo[1] // 199025 ? aDateInfo[2] // 06/17/90 beginning of week 25 ? aDateInfo[3] // 06/23/90 end of week 25 // get info about week 25 in current year( 1991 ) aDateInfo := FT_WEEK( , 25 ) ? aDateInfo[1] // 199025 ? aDateInfo[2] // 06/16/91 beginning of week 25 ? aDateInfo[3] // 06/22/91 end of week 25
FT_WORKDAYS( [ <dStart> ], [ <dStop> ] ) -> nDays
The number of work days (Monday through Friday) between two dates.
FT_WORKDAYS() returns a number indicating the number of work days between two dates. Work days are considered Monday through Friday. (The five day work week none of us Clipper programmers have.)
? FT_WorkDays( CTOD("5/16/91"), CTOD("5/20/91") ) // 3 (Th - Mo) ? FT_WorkDays( CTOD("5/18/91"), CTOD("5/19/91") ) // 0 (Sa - Su) ? FT_WorkDays( CTOD("5/17/91"), CTOD("5/17/91") ) // 1 (Fr - Fr)
FT_WOY( <dDate> ) -> <nResult>
Return numeric position of week within the year or NIL if parameter does not conform.
Considers a full week as starting on Sunday, ending on Saturday. First week of year (week 1) may start on any day, and thus contain any number of days. Final week of year (week 53) may contain any number of days. Handles dates with CENTURY ON|OFF, to allow for 21st century. Date validation must be external to this function.
These code fragments find the week number, given a date. // literal character date dDate := CTOD("01/01/91") nWkNum := FT_WOY(dDate) // result: 1 // presume DOS date to be 01/06/91 nWkNum := FT_WOY(DATE()) // result: 2 // date input cDate := SPACE(8) @ 4,10 get cDate PICT "##/##/##" // input 07/04/91 READ nWkNum := FT_WOY(CTOD(cDate)) // result: 27 // last day of year nWkNum := FT_WOY(CTOD("12/31/91")) // result: 53 For a demonstration of this function, compile and link the program WOY.PRG in the Nanforum Toolkit source code.
FT_YEAR( [ <dGivenDate> ] ) -> aDateInfo
A three element array containing the following data:
aDateInfo[1] - The year as a character string "YYYY" aDateInfo[2] - The beginning date of the year aDateInfo[3] - The ending date of the year
FT_YEAR() returns an array containing data about the year containing the given date.
Normally the return data will be based on a year beginning on January 1st.
The beginning of year date can be changed by using FT_DATECNFG(), which will affect all subsequent calls to FT_YEAR() until another call to FT_DATECNFG().
The beginning of year date may be reset to January 1 by calling FT_DATECNFG() with no parameters.
// Get info about year containing 9/15/90, assuming default // beginning of year is January 1st. aDateInfo := FT_YEAR( Ctod("09/15/90") ) ? aDateInfo[1] // 1990 ? aDateInfo[2] // 01/01/90 beginning of year ? aDateInfo[3] // 12/31/90 end of year // get info about current year (1991). aDateInfo := FT_YEAR() ? aDateInfo[1] // 1991 ? aDateInfo[2] // 01/01/91 beginning of year ? aDateInfo[3] // 12/31/91 end of year
MONTH(<дата>) --> номер месяца
MONTH() возвращает целое число, которое находится в интервале от 0 до 12. Ноль получается при обработке нулевой даты (CTOD("")).
MONTH() - функция обработки даты, которая может быть полезна, если в процессе вычислений необходимо числовое значение месяца. MONTH() входит в группу функций, которые возвращают компоненты даты как целое число. В эту группу также входят функции DAY() и YEAR(), которые возвращают числовые значения дня и года. Функция CMONTH() позволяет по значению даты определить название месяца.
Этот пример определяет номер месяца для системной даты. ? DATE() // Результат: 09/01/90 ? MONTH(DATE()) // Результат: 9 ? MONTH(DATE()+1) // Результат: 10 Следующий пример демонстрирует, как MONTH() обрабатывает нулевую дату. #define NULL DATE (CTOD("")) ? MONTH(NULL DATE) // Результат: 0
SECONDS() --> количество секунд
No arguments
SECONDS() возвращает системное время как числовое значение до сотых долей секунды. Возвращенное числовое значение - это количество секунд, отсчитываемое от полуночи. Диапазон его значений - от 0 до 86399.
SECONDS() - это функция получения времени, используемая для обеспечения простого метода вычисления интервалов времени. Она использует системный таймер. SECONDS() родственна функции TIME(), которая возвращает системное время в виде строки формата чч:мм:сс.
Этот пример сравнивает значения TIME() и SECONDS(): ? TIME() // Результат: 10:00:00 ? SECONDS() // Результат: 36000.00 Этот пример демонстрирует использование SECONDS() для отслеживания времени, отсчитываемого в секундах: LOCAL nStart, nElapsed nStart = SECONDS() ... ...<операторы> ... nElapsed = SECONDS() - nStart ? "Прошло :" + LTRIM(STR(nElapsed)) + " секунд"
TIME() --> системное время.
No arguments
TIME() возвращает системное время в виде символьной строки в формате чч:мм:сс, где чч - часы, мм - минуты, сс - секунды. Часы, минуты и секунды разделяются двоеточием.
TIME() - функция получения времени, используемая для вызова на экран или печатающее устройство системного времени. TIME() связана с функцией SECONDS(), которая возвращает количество секунд с начала суток. Вместо TIME() для вычислений обычно используется SECONDS().
Следующие примеры показывают результаты работы функции TIME() в сочетании с SUBSTR() для выделения количества часов, минут и секунд: ? TIME() // Результат: 10:37:17 ? SUBSTR(TIME(), 1, 2) // Результат: 10 ? SUBSTR(TIME(), 4, 2) // Результат: 37 ? SUBSTR(TIME(), 7, 2) // Результат: 17
YEAR (<дата>) --> год
YEAR() возвращает номер года, заданного значением даты в виде четырехзначного числового значения. На возвращаемое значение не влияют установки форматов DATE и CENTURY. Заданная нулевая дата (CTOD("")) возвращает ноль.
YEAR() - функция преобразования даты, которая используется для перевода заданной даты в числовое значение года. Функция может быть использована при вычислениях или для форматирования дат. YEAR() входит в группу функций, которые возвращают компоненты дат в виде чисел. К этой группе относятся также функции DAY() и MONTH(), которые возвращают значения дня и месяца в виде числовых значений.
Следующий пример демонстрирует использование функции YEAR(). ? DATE() // Результат: 09/01/90 ? YEAR (DATE() ) // Результат: 1990 ? YEAR (DATE () ) + 11 // Результат: 2001 Этот пример создает функцию пользователя, применяющую функцию YEAR() для форматирования значения даты в форме месяц, день, год: ? Mdy(DATE () ) // Результат; September 20,1990 FUNCTION Mdy ( dDate ) RETURN Mdy ( dDate ) + " " + LTRIM(STR(DAY(dDate))); + "," + STR(YEAR(dDate))
Пред. | Начало | След. |
NETWARE | Уровень выше | KEYBOARD/MOUSE |