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

Time()

Time()

Returns the system time as a string

Syntax

      Time() --> cTime

Arguments

None

Returns

<cTime> Character string representing time

Description

This function returns the system time represented as a character expression in the format of HH:MM:SS

Examples

      ? Time()

Compliance

Clipper

Platforms

All

Files

Library is core

Seealso

Date(), Seconds()

Secs()

Secs()

Return the number of seconds from the system date.

Syntax

      Secs( <cTime> ) --> nSeconds

Arguments

<cTime> Character expression in a time string format

Returns

<nSeconds> Number of seconds

Description

This function returns a numeric value that is a number of elapsed seconds from midnight based on a time string given as <cTime>.

Examples

      ? Secs( Time() )
      ? Secs( Time() - 10 )

Compliance

Clipper

Platforms

All

Files

Library is core

Seealso

Seconds(), ElapTime(), Time()

ElapTime()

ELAPTIME()

Calculates elapted time.

Syntax

      ELAPTIME(<cStartTime>,<cEndTime>) --> cDiference

Arguments

<cStartTime> Start in time as a string format <cEndTime> End time as a string format

Returns

<cDiference> Difference between the times

Description

This function returns a string that shows the difference between the starting time represented as <cStartTime> and the ending time as <cEndTime>. If the stating time is greater then the ending time, the function will assume that the date changed once.

Examples

      STATIC s_cStartTime
      INIT PROCEDURE Startup()
         s_cStartTime := Time()
         RETURN
      EXIT PROCEDURE StartExit()
         ? "You used this program by", ElapTime( s_cStartTime, Time() )
         RETURN

Compliance

Clipper

Platforms

All

Files

Library is rtl

Seealso

SECS(), SECONDS(), TIME(), DAY()

Days()

 

DAYS()

Convert elapsed seconds into days

Syntax

      DAYS(<nSecs> ) --> nDay

Arguments

<nSecs> The number of seconds

Returns

<nDay> The number of days

Description

This function converts <nSecs> seconds to the equivalent number of days; 86399 seconds represents one day, 0 seconds being midnight.

Examples

      ? Days( 2434234 )
      ? "Has been passed", Days( 63251 ), "since midnight"

Compliance

Clipper

Platforms

All

Files

Library is rtl

Seealso

SECONDS(), SECS(), ELAPTIME()

SP_P_READY

P_READY()

  Short:
  ------
  P_READY() Determines if printer is ready, prompts user

  Returns:
  --------
  <lReady> => True if printer is ready

  Syntax:
  -------
  P_READY([cPort])

  Description:
  ------------
  Checks for printer ready, and prompts user to ready
  the printer until it is ready, or until user presses escape to
  abort printing.

  P_READY() first looks at SLS_PRNC(), and if the
  value is .f., does no printer check and returns .t.

  [cPort] - LPT1 LPT2 LPT3
  Default is LPT1

  Examples:
  ---------
   if P_READY("LPT2")
     REPORT FORM yayaya TO PRINT
   ENDIF

  Notes:
  -------
  To stop P_READY() from checking the printer port (as
  it is imbedded in many SuperLib functions), call SLS_PRNC() with
  False. This turns printer checking off. (i.e. on a network)

  Source:
  -------
  S_PREAD.PRG

See also : P_RDYDELAY(), P_READY(), SLS_PRNC()

 

 

SP_P_RDYDELAY

P_RDYDELAY()

  Short:
  ------
  P_RDYDELAY() Sets/returns p_ready() 'seconds' variable

  Returns:
  --------
  <nSeconds> => p_ready() seconds variable

  Syntax:
  -------
  P_RDYDELAY([nSeconds])

  Description:
  ------------
  P_READY() tries for 5 seconds by default to check the printer
  for readiness. This function retrieves/sets the variable that
  controls the # of seconds to try for.

  Examples:
  ---------
  P_RDYDELAY(10)

  Source:
  -------
  S_PREAD.PRG

C5_SECONDS

 SECONDS()
 Return the number of seconds elapsed since midnight
------------------------------------------------------------------------------
 Syntax

     SECONDS() --> nSeconds

 Returns

     SECONDS() returns the system time as a numeric value in the form
     seconds.hundredths.  The numeric value returned is the number of seconds
     elapsed since midnight, and is based on a twenty-four hour clock in a
     range from 0 to 86399.

 Description

     SECONDS() is a time function that provides a simple method of
     calculating elapsed time during program execution, based on the system
     clock.  It is related to the TIME() function which returns the system
     time as a string in the form hh:mm:ss.

 Examples

     .  This example contrasts the value of TIME() with SECONDS():

        ? TIME()               // Result: 10:00:00
        ? SECONDS()            // Result: 36000.00

     .  This example uses SECONDS() to track elapsed time in seconds:

        LOCAL nStart, nElapsed
        nStart:= SECONDS()
        .
        . <statements>
        .
        nElapsed:= SECONDS() - nStart
        ? "Elapsed: " + LTRIM(STR(nElapsed)) + " seconds"

 Files   Library is CLIPPER.LIB.

See Also: TIME()



C5 Data Manipulation Functions

Array :

AADD() :

Add a new element to the end of an array

AADD( <aTarget>, <expValue> ) --> Value

ACLONE() :

Duplicate a nested or multidimensional array

ACLONE( <aSource> ) --> aDuplicate

ACOPY() :

Copy elements from one array to another

ACOPY( <aSource>, <aTarget>, [ <nStart> ], [ <nCount> ], 
    [ <nTargetPos> ] ) --> aTarget

ADEL() :

Delete an array element

ADEL( <aTarget>, <nPosition> ) --> aTarget

ADIR()* :

Fill a series of arrays with directory information

ADIR([ <cFilespec> ],
    [ <aFilenames> ],
    [ <aSizes> ],
    [ <aDates> ],
    [ <aTimes> ],
    [ <aAttributes> ] ) --> nFiles

AEVAL() :

Execute a code block for each element in an array

AEVAL( <aArray>, <bBlock>, [ <nStart> ], [ <nCount> ] ) --> aArray

AFILL() :

Fill an array with a specified value

AFILL( <aTarget>, <expValue>, [ <nStart> ], [ <nCount> ] )
       --> aTarget

AINS() :

Insert a NIL element into an array

AINS( <aTarget>, <nPosition> ) --> aTarget

ARRAY() :

Create an uninitialized array of specified length

ARRAY( <nElements> [, <nElements>...] ) --> aArray

ASCAN() :

Scan an array for a value or until a block returns (.T.)

ASCAN( <aTarget>, <expSearch>, [ <nStart> ], [ <nCount> ] )
      --> nStoppedAt

ASIZE() :

Grow or shrink an array

ASIZE( <aTarget>, <nLength> ) --> aTarget

ASORT() :

Sort an array

ASORT( <aTarget>, [ <nStart> ], [ <nCount> ], [ <bOrder> ] )
       --> aTarget

ATAIL() :

Return value of the highest numbered (last) element of an array

ATAIL( <aArray> ) --> Element

Common :

EMPTY() :

Determine if the result of an expression is empty

EMPTY( <exp> ) --> lEmpty

LEN() :

Return the length of a character string or array size

LEN( <cString> | <aArray> ) --> nCount

MAX() :

Return the larger of two numeric or date values

MAX( <nExp1>, <nExp2> ) --> nLarger
MAX( <dExp1>, <dExp2> ) --> dLarger

MIN() :

Return the smaller of two numeric or date values

MIN( <nExp1>, <nExp2> ) --> nSmaller
MIN( <dExp1>, <dExp2> ) --> dSmaller

PAD() :

Pad character, date or numeric values with a fill character

PADL( <exp>, <nLength>, [ <cFillChar> ] ) --> cPaddedString
PADC( <exp>, <nLength>, [ <cFillChar> ] ) --> cPaddedString
PADR( <exp>, <nLength>, [ <cFillChar> ] ) --> cPaddedString

TRANSFORM() :

Convert any value into a formatted character string

TRANSFORM( <exp>, <cSayPicture> ) --> cFormatString

TYPE() :

Determine the type of an expression

TYPE( <cExp> ) --> cType

VALTYPE() :

Determine the data type returned by an expression

VALTYPE( <exp> ) --> cType

Date & Time :

CDOW() :

Convert a date value to a character day of the week

CDOW( <dExp> ) --> cDayName

CMONTH() :

Convert a date to a character month name

CMONTH( <dDate> ) --> cMonth

CTOD() :

Convert a date string to a date value

CTOD( <cDate> ) --> dDate

DATE() :

Return the system date as a date value

DATE() --> dSystem

DAY() :

Return the day of the month as a numeric value

DAY( <dDate> ) --> nDay

DOW() :

Convert a date value to a numeric day of the week

DOW( <dDate> ) --> nDay

DTOC() :

Convert a date value to a character string

DTOC( <dDate> ) --> cDate

DTOS() :

Convert a date value to a string formatted as yyyymmdd

DTOS( <dDate> ) --> cDate

MONTH() :

Convert a date value to the number of the month

MONTH( <dDate> ) --> nMonth

SECONDS() :

Return the number of seconds elapsed since midnight

SECONDS() --> nSeconds

TIME() :

Return the system time

TIME() --> cTimeString

YEAR() :

Convert a date value to the year as a numeric value

YEAR( <dDate> ) --> nYear

Numeric :

ABS() :

Return the absolute value of a numeric expression

ABS( <nExp> ) --> nPositive

BIN2I() :

Convert a 16-bit signed integer to a numeric value

BIN2I( <cSignedInt> ) --> nNumber

BIN2L() :

Convert a 32-bit signed integer to a numeric value

BIN2L( <cSignedInt> ) --> nNumber

BIN2W() :

Convert a 16-bit unsigned integer to a numeric value

BIN2W( <cUnsignedInt> ) --> nNumber

EXP() :

Calculate e**x

EXP( <nExponent> ) --> nAntilogarithm

INT() :

Convert a numeric value to an integer

INT( <nExp> ) --> nInteger

I2BIN() :

Convert a numeric to a 16-bit binary integer

I2BIN( <nInteger> ) --> cBinaryInteger

LOG() :

Calculate the natural logarithm of a numeric value

LOG( <nExp> ) --> nNaturalLog

L2BIN() :

Convert a numeric value to a 32-bit binary integer

L2BIN( <nExp> ) --> cBinaryInteger

MOD()* :

Return dBASE III PLUS modulus of two numbers

MOD( <nDividend>, <nDivisor> ) --> nRemainder

ROUND() :

Return a value rounded to a specified number of digits

ROUND( <nNumber>, <nDecimals> ) --> nRounded

SQRT() :

Return the square root of a positive number

SQRT( <nNumber> ) --> nRoot

VAL() :

Convert a character number to numeric type

VAL( <cNumber> ) --> nNumber

String & Memo :

ALLTRIM() :

Remove leading and trailing spaces from character string

ALLTRIM( <cString> ) --> cTrimString

ASC() :

Convert a character to its ASCII value

ASC( <cExp> ) --> nCode

AT() :

Return the position of a substring within a string

AT( <cSearch>, <cTarget> ) --> nPosition

CHR() :

Convert an ASCII code to a character value

CHR( <nCode> ) --> cChar

HARDCR() :

Replace all soft CRs with hard CRs

HARDCR( <cString> ) --> cConvertedString

ISALPHA() :

Determine if the leftmost character is alphabetic

ISALPHA( <cString> ) --> lBoolean

ISDIGIT() :

Determine if the leftmost character is a digit

ISDIGIT( <cString> ) --> lBoolean

ISLOWER() :

Determine if the leftmost character is a lower case letter

ISLOWER( <cString> ) --> lBoolean

ISUPPER() :

Determine if the leftmost character is upper case

ISUPPER( <cString> ) --> lBoolean

LEFT() :

Extract a substring beginning with the first character

LEFT( <cString>, <nCount> ) --> cSubString

LOWER() :

Convert uppercase characters to lowercase

LOWER( <cString> ) --> cLowerString

LTRIM() :

Remove leading spaces from a character string

LTRIM( <cString> ) --> cTrimString

MEMOEDIT() :

Display or edit character strings and memo fields

MEMOEDIT( [ <cString> ],
    [ <nTop> ], [ <nLeft> ],
    [ <nBottom> ], [ <nRight> ],
    [ <lEditMode> ],
    [ <cUserFunction> ],
    [ <nLineLength> ],
    [ <nTabSize> ],
    [ <nTextBufferRow> ],
    [ <nTextBufferColumn> ],
    [ <nWindowRow> ],
    [ <nWindowColumn> ] ) --> cTextBuffer

MEMOLINE() :

Extract a line of text from character string or memo field

MEMOLINE( <cString>,
    [ <nLineLength> ],
    [ <nLineNumber> ],
    [ <nTabSize> ],
    [ <lWrap> ] ) --> cLine

MEMOREAD() :

Return the contents of a disk file as a character string

MEMOREAD( <cFile> ) --> cString

MEMOTRAN() :

Replace carriage return/line feeds in character strings

MEMOTRAN( <cString>,
    [ <cReplaceHardCR> ],
    [ <cReplaceSoftCR> ] ) --> cNewString

MEMOWRIT() :

Write a character string or memo field to a disk file

MEMOWRIT( <cFile>, <cString> ) --> lSuccess

MLCOUNT() :

Count the lines in a character string or memo field

MLCOUNT( <cString>, [ <nLineLength> ],  [ <nTabSize> ],
         [ <lWrap> ] ) --> nLines

MLCTOPOS() :

Return byte position based on line and column position

MLCTOPOS( <cText>, <nWidth>, <nLine>,
    <nCol>, [ <nTabSize> ], [ <lWrap> ] ) --> nPosition

MLPOS() :

Determine the position of a line in a memo field

MLPOS( <cString>, <nLineLength>,
     <nLine>, [ <nTabSize> ], [ <lWrap> ] ) --> nPosition

MPOSTOLC() :

Return line and column position based on byte position

MPOSTOLC( <cText>, <nWidth>, <nPos>,
     [ <nTabSize> ], [ <lWrap> ] ) --> aLineColumn

RAT() :

Return the position of the last occurrence of a substring

RAT( <cSearch>, <cTarget> ) --> nPosition

REPLICATE() :

Return a string repeated a specified number of times

REPLICATE( <cString>, <nCount> ) --> cRepeatedString

RIGHT() :

Return a substring beginning with rightmost character

RIGHT( <cString>, <nCount> ) --> cSubString

RTRIM() :

Remove trailing spaces from a character string

RTRIM( <cString> ) --> cTrimString

SET EXACT* :

Toggle exact matches for character strings

SET EXACT on | OFF | <xlToggle>

SOUNDEX() :

Convert a character string to soundex form

SOUNDEX( <cString> ) --> cSoundexString

SPACE() :

Return a string of spaces

SPACE( <nCount> ) --> cSpaces

STR() :

Convert a numeric expression to a character string

STR( <nNumber>, [ <nLength> ], [ <nDecimals> ] ) --> cNumber

STRTRAN() :

Search and replace characters within a character string

STRTRAN( <cString>, <cSearch>, [ <cReplace> ],
    [ <nStart> ], [ <nCount> ] ) --> cNewString

STUFF() :

Delete and insert characters in a string

STUFF( <cString>, <nStart>, <nDelete>, <cInsert> ) --> cNewString

SUBSTR() :

Extract a substring from a character string

SUBSTR( <cString>, <nStart>, [ <nCount> ] ) --> cSubstring

TRIM() :

Remove trailing spaces from a character string

TRIM( <cString> ) --> cTrimString

UPPER() :

Convert lowercase characters to uppercase

UPPER( <cString> ) --> cUpperString