Date & Time Functions

Date & Time Functions

ADays Returns an array with the days names
AddMonth Adds or subtracts months to/from a date
AMonths Returns an array with the months names
BOM Beginning date Of Month of given date
BOQ Date of beginning Of quarter containing given date
BOY Date to find first day of year, default is DATE()
CDoW Converts a date to the day of week
CMonth Return the name of the month
CToD Converts a character string to a date expression
CToDoW Convert name of day of the week to its ordinal number
CToMonth Convert name of month to its ordinal number
Date Return the Current OS Date
Day Return the numeric day of the month
Days Convert elapsed seconds into days
DaysInMonth Returns the number of days in month
DaysToMonth Total number of days from first of Jan to beginning of nMonth
DMY Returns the date as a string in DD Month YY format
DoW Value for the day of week
DOY Determines the day of the year for a specific date
DToC Date to character conversion
DToS Date to string conversion
ElapTime Calculates elapted time
EOM End Of Month
EOQ Date of end of quarter
EOY Last date Of Year
IsLeap Tests if a specific year is a leap year
IsLeapYear Checks if the given date is a leap year
LastDayOM Determines the number of days in a month
MDY Returns the date as a string in Month DD, YY or Month DD, YYYY
Month Converts a date expression to a month value
NToCDoW Find day name by num of day
NToCMonth Find a month name by the number of month
Quarter Returns a number equal to the quarter in which a date falls
Seconds Returns the number of elapsed seconds past midnight
Secs Return the number of seconds from the system date
SecToTime Converts seconds into a time string
Time Returns the system time as a string
TimeValid Determines whether a specified time is valid
TimeToSec Calculates the seconds since midnight
WaitPeriod Pauses a specified time in increments of 1/100 seconds
Week Returns the calendar week a number
WOY Gets the week number of the year
Year Converts the year portion of a date into a numeric value

Commands

User Interface

? | ?? Display one or more values to the console
@…BOX Draw a box on the screen
@…CLEAR Clear a rectangular region of the screen
@…GET Build a new Get object and display it to the screen
@…PROMPT Paint a menu item and define a message
@…SAY Display data at a specified screen or printer row and column
@…TO Draw a single- or double-line box
ACCEPT* Place keyboard input into a memory variable
CLEAR TYPEAHEAD Empty the keyboard buffer
DISPLAY Display records to the console
INPUT* Enter the result of an expression into a variable
KEYBOARD Stuff a string into the keyboard buffer
LIST List records to the console
MENU TO Execute a lightbar menu for defined PROMPTs
READ Activate full-screen editing mode using Get objects
RESTORE SCREEN* Display a saved screen
SAVE SCREEN* Save the current screen to a buffer or variable
SET BELL Toggle sounding of the bell during full-screen operations
SET COLOR* Define screen colors
SET CONFIRM Toggle required exit key to terminate GETs
SET CONSOLE Toggle console display to the screen
SET CURSOR Toggle the screen cursor on or off
SET DECIMALS Set the number of decimal places to be displayed
SET DELIMITERS Toggle or define GET delimiters
SET ESCAPE Toggle Esc as a READ exit key
SET FIXED Toggle fixing of the number of decimal digits displayed
SET FORMAT* Activate a format when READ is executed
SET FUNCTION Assign a character string to a function key
SET INTENSITY Toggle enhanced display of GETs and PROMPTs
SET MESSAGE Set the @…PROMPT message line row
SET SCOREBOARD Toggle the message display from READ or MEMOEDIT()
SET TYPEAHEAD Set the size of the keyboard buffer
SET WRAP* Toggle wrapping of the highlight in menus
TEXT* Display a literal block of text
WAIT* Suspend program processing until a key is pressed

Database

APPEND BLANK Add a new record to the current database file
APPEND FROM Import records from a database (.dbf) file or ASCII text file
AVERAGE Average numeric expressions in the current work area
CONTINUE Resume a pending LOCATE
COPY STRUCTURE Copy the current .dbf structure to a new database (.dbf) file
COPY STRUCTURE EXTENDED Copy field definitions to a .dbf file
COPY TO Export records to a database (.dbf) file or ASCII text file
COUNT Tally records to a variable
CREATE Create an empty structure extended (.dbf) file
CREATE FROM Create a new .dbf file from a structure extended file
DELETE Mark records for deletion
DELETE TAG Delete a tag
FIND* Search an index for a specified key value
GO Move the pointer to the specified identity
INDEX Build an index file
JOIN Build new database file by merging from two work areas
LOCATE Search sequentially for a record matching a condition
PACK Remove deleted records from a database file
RECALL Restore records marked for deletion
REINDEX Rebuild open indexes in the current work area
REPLACE Assign new values to field variables
SEEK Search an order for a specified key value
SELECT Change the current work area
SET AUTOPEN Toggles automatic opening of a structural index file
SET AUTORDER Defines the default controlling index for automatically opened index files
SET AUTOSHARE Defines network detection for shared file access
SET DELETED Toggle filtering of deleted records
SET DESCENDING Change the descending flag of the controlling order
SET EXCLUSIVE* Establish shared or exclusive USE of database files
SET FILTER Hide records not meeting a condition
SET INDEX Open one or more order bags in the current work area
SET MBLOCKSIZE Change the block size for memo files
SET ORDER Select the controlling order
SET RELATION Relate two work areas by a key value or record number
SET SCOPE Change the boundaries for scoping keys in controlling order
SET SCOPEBOTTOM Change bottom boundary for scoping keys in controlling order
SET SCOPETOP Change top boundary for scoping keys in controlling order
SET SOFTSEEK Toggle relative seeking
SET STRICTREAD Toggles read optimization for database access
SET UNIQUE* Toggle inclusion of non-unique keys into an index
SKIP Move the record pointer to a new position
SORT Copy to a database (.dbf) file in sorted order
SUM Sum numeric expressions and assign results to variables
TOTAL Summarize records by key value to a database (.dbf) file
UNLOCK Release file/record locks set by the current user
UPDATE Update current database file from another database file
USE Open an existing database (.dbf) and its associated files
ZAP Remove all records from the current database file

Program Execution

CANCEL Terminate program processing
DO* Executes a function or procedure
QUIT Terminate program processing
RUN Execute a OS command or program
SET KEY Assign a procedure invocation to a key
NOTE* Place a single-line comment in a program file
SET PROCEDURE* Compile procedures and functions into the current object file

Variable Management

CLEAR ALL* Close files and release public and private variables
CLEAR GETS Release Get objects from the current GetList array
CLEAR MEMORY Release all public and private variables
CLEAR SCREEN Clear the screen and return the cursor home
RELEASE Delete public and private memory variables
RESTORE Retrieve memory variables from a memory (.mem) file
SAVE Save variables to a memory (.mem) file
STORE* Assign a value to one or more variables
SET EXACT Toggle exact matches for character strings

Device, Files & Folders

CLOSE Close a specific set of files
COMMIT Perform a solid-disk write for all active work areas
COPY FILE Copy a file to a new file or to a device
DELETE FILE Remove a file from disk
DIR* Display a listing of files from a specified path
ERASE Remove a file from disk
RENAME Change the name of a file
SET ALTERNATE Echo console output to a text file
SET DEFAULT Set the application default drive and directory
SET DEVICE Direct @…SAYs to the screen or printer
SET PATH Specify the CA-Clipper search path for opening files
TYPE Display the contents of a text file

Printer

EJECT Advance the printhead to top of form
SET MARGIN Set the page offset for all printed output
SET PRINTER Toggle echo of output to printer or set the print destination

Label / Report

LABEL FORM Display labels to the console
REPORT FORM Display a report to the console

Date & Time

SET CENTURY Modify the date format to include or omit century digits
SET DATE Set the date format for input and display
SET EPOCH Control the interpretation of dates with no century digits

All

CT_DMY

 DMY()
 Returns a date in "DD Month YY" format
------------------------------------------------------------------------------
 Syntax

     DMY([<dDate>], [<lMode>]) --> cDate

 Arguments

     <dDate>  Designates the date from which to create a string.  The
     default is the system date.

     <lMode>  Designates whether to insert a period (.) after the day
     (see Examples).  The default is no period (.F.).

 Returns

     DMY() returns a character string in "DD[.] Month YY" format or "DD[.]
     Month YYYY" format.

 Description

     Use DMY() to return the date as a character string using the day, name
     of month, and year.  The CA-Clipper SET CENTURY ON/OFF switch determines
     whether or not the year is displayed in two or four digits.  If the
     <lMode> parameter is designated .T., the function builds in a "." after
     the day designation. If no date is designated as a parameter, the
     function automatically uses the current system date.

 Note

     .  The month name returned depends on which CA-Clipper nations
        module is in use.

 Examples

     .  Display the system date (1/1/89):

        SET CENTURY OFF
        ? DMY()                            // 1 January 89

     .  With ".":

        ? DMY(.T.)                         // 1. January 89

     .  Display a different date:

        SET CENTURY ON
        ? DMY(CTOD("02/01/89"), .T.)       // 1. February 1989

See Also: MDY()

CT_CToMonth()

 CTOMONTH()
 Converts the name of the month into a corresponding number
------------------------------------------------------------------------------
 Syntax

     CTOMONTH(<cMonth>) --> nMonth

 Argument

     <cMonth>  Designates the name of one of the 12 months.

 Returns

     CTOMONTH() returns the number for the designated month name.

 Description

     Use CTOMONTH() to change the name of a month into a number.  January
     corresponds to 1, February 2, etc..  If the function returns a 0 value,
     then an invalid parameter has been passed.  If you shorten the month
     name, use explicit abbreviations to return an accurate return value.

 Notes

     .  Uppercase and lowercase letters do not affect the name of the
        month.

     .  The function's operation depends on the country-specific
        adaptation of your CA-Clipper compiler.  With an English version of
        CA-Clipper, only English month names are recognized.

 Examples

     .  Show the number for January:

        ? CTOMONTH("January")      // Result: 1

     .  Show several ways to determine the month number for August:

        ? CTOMONTH("AUGUST")       // Result: 8
        ? CTOMONTH("August")       // Result: 8
        ? CTOMONTH("Au")           // Result: 8

     .  The number for April:

        ?CTOMONTH("A")             // Result: 4

CT_AddMonth()

ADDMONTH()
 Adds or subtracts months to/from a date
------------------------------------------------------------------------------
 Syntax

     ADDMONTH([<dDate>], [<nMonth>]) --> dNewDate

 Arguments

     <dDate>  Designates the date to which the <nMonth> months is added.
     The default is the system date.

     <nMonth>  Designates the number of months to add to <dDate>.

 Returns

     ADDMONTH() returns the new date after <nMonth> is added to <dDate>.

 Description

     Use this function to calculate payment due dates based on an invoice
     date and for similar applications.  It permits you to add months to a
     given date.  If you use a negative number, months are subtracted.

 Note

     .  An empty date parameter will result in an empty date.

 Examples

     * Show today's date, plus 36 months:

     ? "The payment period ends on: ", ADDMONTH(36)

     * Today plus 7 month: 
     ? "AddMonth( 7 ) :", AddMonth( 7 )

     * Date of last day of 7 month after :
     ? "EOM( AddMonth( 7 ) ) :", EOM( AddMonth( 7 ) )

     * Dates of next year: 
     dDate := CTOD( "12.12.2012" )
     ? "Last day of one month after", dDate, ":", EOM( AddMonth( dDate, 1 ) )
     ? "Last day of two month after", dDate, ":", EOM( AddMonth( dDate, 2 ) )
     
     * Month before 
     ? "Date of two month before", dDate, ":", AddMonth( dDate, -2 )
     ?

CT_CToDoW()

  NAME :
     CToDoW()
  CATEGORY :
     CT3 date and time functions
  ONELINER :
     Convert name of day of the week to its ordinal number
  SYNTAX :
     CToDoW( <cDayName> ) -> <nOrdinal>
  ARGUMENT :
     <cDayName> : Name of day to convert to ordinal number
  RETURN :
     <nOrdinal> : Ordinal number of <cDayName>
  EXAMPLE :
 PROC MAIN()
    SETMODE( 25, 80 )
    CLS
    SET DATE GERM
    SET CENT ON
    ? "CTODOW('Sunday') :", CTODOW('Sunday') // 1
    *  Show several ways to get the day of
    *  the week for Wednesday:
    ? "CTODOW('WEDNESDAY') :", CTODOW('WEDNESDAY')      // 4
    ? "CTODOW('Wednesday') :", CTODOW('Wednesday')      // 4
    ? "CTODOW('Wed') :",CTODOW('Wed')                   //  4
    *  What number of the day of the week is Monday?
    ? "CTODOW( 'M' ) :", CTODOW( 'M' ) //  2
    ?
    WAIT "EOF CTODOW.prg"
 RETURN // MAIN
  COMPLIANCE :
     CToDoW() is compatible with CT3's CToDoW()
  PLATFORMS :
     All
  FILES :
     Library is hbct.
  SEE ALSO :
     NToCDoW()


CT_EoY()

  NAME :
     EoY()
  CATEGORY :
     CT3 date and time functions
  SYNTAX :
     EoY( [<dDate>] ) -> dDateEndOfYear
  ARGUMENT :
     [<dDate>] : Date to find last day of year, default is DATE()
  RETURNS :
     <dDateEndOfYear> : Last date Of Year of given date
  EXAMPLE :
 PROC MAIN()
    SETMODE( 25, 80 )
    CLS
    SET DATE GERM
    SET CENT ON
    ? "Today is :", DATE()
    ? "Last day of this year :", EoY()
    ? "Remaining days in the current year:", EoY() - DATE()
    ?
    WAIT "EOF EoY.prg"
 RETURN // MAIN
  COMPLIANCE :
     EoY() is compatible with CT3's EoY()
  PLATFORMS :
     All
  FILES :
     Library is hbct
  SEE ALSO :
     BoM(),EoM(),BoQ(),EoQ(),BoY()

CT_BoY()

  NAME :
     BoY()
  CATEGORY :
     CT3 date and time functions
  SYNTAX :
     BoY( [<dDate>] ) -> dDateBeginOfYear
  ARGUMENT :
     [<dDate>] : Date to find first day of year, default is DATE()
  RETURNS :
     <dDateBeginOfYear> : Beginning date Of year of given date
  EXAMPLE :
 PROC MAIN()
    SETMODE( 25, 80 )
    CLS
    SET DATE GERM
    SET CENT ON
    ? "Today is :", DATE()
    ? "Date of first day of this year :", BOY()
    ? "Days elapsed in the current year:", DATE() - BOY()
    ?
    WAIT "EOF BoY.prg"
 RETURN // MAIN
  COMPLIANCE :
     BoY() is compatible with CT3's BoY()
  PLATFORMS :
     All
  FILES :
     Library is hbct.
  SEE ALSO :
     BoM(),EoM(),BoQ(),EoQ(),EoY()


CT_EoQ()

  NAME
     EoQ()
  CATEGORY
     CT3 date and time functions
  SYNTAX
     EoQ( [<dDate>] ) -> dDateEndOfQ
  ARGUMENT:
     [<dDate>] : Date to find end of quarter, default is DATE()
  RETURNS:
     <dDateEndOfQuarter> : Date of end of quarter containing given date
  EXAMPLE :
     PROC MAIN()
        SETMODE( 25, 80 )
        CLS
        SET DATE GERM
        SET CENT ON
        ? "Today is :", DATE()
        ? "Last day of this quarter
        ? "Days remaininng in the cu
        ?
        WAIT "EOF EOQ.prg"
     RETURN // MAIN
  COMPLIANCE :
     EoQ() is compatible with CT3's
  PLATFORMS :
     All
  FILES :
     Library is hbct.
  SEE ALSO :
     BoM(),EoM(),BoQ(),BoY(),EoY()

CT_BoQ()

  NAME :
     BoQ()
  CATEGORY :
     CT3 date and time functions
  SYNTAX :
     BoQ( [<dDate>] ) -> <dDateBeginOfQuarter>
  ARGUMENT :
     [<dDate>] : Date to find Begin Of Quarter, default is DATE()
  RETURNS :
     <dDateBeginOfQuarter> : Date of beginning Of quarter containing given date
  EXAMPLE :
     PROC MAIN()
        SETMODE( 25, 80 )
        CLS
        SET DATE GERM
        SET CENT ON
        ? "Today is :", DATE()
        ? "Beginning day of this quarter :", BOQ()
        ? "Days elapsed in the current quarter :", DATE() - BOQ()
        ?
        WAIT "EOF BOQ.prg"
     RETURN // MAIN
  COMPLIANCE :
     BoQ() is compatible with CT3's BoQ()

  PLATFORMS :
     All
  FILES :
     Library is hbct.
  SEE ALSO :
     BoM(), EoM(), EoQ(), BoY(), EoY()