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

Year()

Year()

Converts the year portion of a date into a numeric value

Syntax

      Year(<cDate>) --> nYear

Arguments

<dDate> Any valid date expression

Returns

<nYear> The year portion of the date.

Description

This function returns the numeric value for the year in <dDate>. This value will always be a four-digit number and is not affected by the setting of the SET CENTURY and SET DATE commands.

Addition ally, an empty date expression passed to this function will yield a zero value.

Examples

      ? Year( Date() )
      ? Year( hb_SToD( "32510125" ) )

Compliance

Clipper

Platforms

All

Files

Library is core

Seealso

Day(), Month()

Day()

 

DAY()

Return the numeric day of the month.

Syntax

      DAY(<cDate>) --> nMonth

Arguments

<cDate> Any valid date expression.

Returns

<nMonth> Numeric value of the day of month.

Description

This function returns the numeric value of the day of month from a date.

Examples

      ? Day( Date() )
      ? Day( Date() + 6325 )

Compliance

Clipper

Platforms

All

Files

Library is rtl

Seealso

CTOD(), DTOS(), DTOC(), DATE(), MONTH(), CMONTH()

Date()

 

DATE()

 

Return the Current OS Date

Syntax

      DATE() --> dCurDate

Arguments

None

Returns

<dCurDate> Current system date.

Description

This function returns the current system date.

Examples

      ? Date()

Tests

      ? "Today is ",Day(Date())," of ",cMonth(Date())," of ",Year(Date())

Compliance

Clipper

Platforms

All

Files

Library is rtl

Seealso

CTOD(), DTOS(), DTOC(), DAY(), MONTH(), CMONTH()

CMonth()

 

CMONTH()

Return the name of the month.

Syntax

      CMONTH(<dDate>)  --> cMonth

Arguments

<dDate> Any date expression.

Returns

<cMonth> The current month name

Description

This function returns the name of the month (January, February, etc.) from a date expression <dDate> passed to it. If a NULL date is passed to the function, the value of the function will be a NULL byte.

Examples

      ? CMonth( Date() )
      IF CMonth( Date() + 10 ) =="March"
         ? "Have you done your system BACKUP?"
      ENDIF

Compliance

Clipper

Platforms

All

Files

Library is rtl

Seealso

CDOW(), DATE(), MONTH(), YEAR(), DOW(), DTOC()

SP_DAYSIN

DAYSIN()

  Short:
  ------
  DAYSIN() Calculates number of days in a month

  Returns:
  --------
  <nDays> => days in month of target date

  Syntax:
  -------
  DAYSIN(dTarget)

  Description:
  ------------
  Returns # of days in month in which <dTarget> falls

  Examples:
  ---------
   dDate    := ctod("10/15/89")

   nDimonth := DAYSIN(dDate)  // (returns 31)

  Source:
  -------
  S_DAYSIN.PRG

 

SP_BOM

BOM()

  Short:
  ------
  BOM() Calculates beginning of the month date

  Returns:
  --------
  <dReturn> => Date which is beginning of the month

  Syntax:
  -------
  BOM(dTarget)

  Description:
  ------------
  Calculates date which is beginning of the month from
  <dTarget>

  Examples:
  ---------
   dDate := ctod("10/15/90")

   dBom  := BOM(DDate)    //    => 10/01/90

  Source:
  -------
  S_BOM.PRG

 

SP_BEGEND

BEGEND()

  Short:
  ------
  BEGEND() Determines beginning or end of week,month or quarter

  Returns:
  --------
  <dReturnDate> => Date of  beginning/end of week,month,qtr

  Syntax:
  -------
  BEGEND(dStartDate,nBeginEnd,nWkMnthQtr,[nDayofWeek])

  Description:
  ------------
  Returns date which is beginning (1) or end (0)
  <nBeginEnd> of week (1) , month (2) ,or quarter (3)
  <nWkMnthQtr> in which input date <dStartDate> falls. If week,
  [nDayofWeek] is day of the week beginning or end of the week
  <nBeginEnd> falls on, with Sunday being 1 and Saturday being 7.

  Examples:
  ---------
   dDate := ctod("01/15/90")
   bow   := BEGEND(dDate,1,1,1)  // beg of week
   eow   := BEGEND(dDate,0,1,7)  // end of week
   bom   := BEGEND(dDate,1,2)    // beg of month
   eow   := BEGEND(dDate,0,2)    // end of month
   boq   := BEGEND(dDate,1,3)    // beg of quarter
   eoq   := BEGEND(dDate,0,3)    // end of quarter

  Source:
  -------
  S_BEGEND.PRG

 

C5_MONTH

 MONTH()
 Convert a date value to the number of the month
------------------------------------------------------------------------------
 Syntax

     MONTH(<dDate>) --> nMonth

 Arguments

     <dDate> is the date value to be converted.

 Returns

     MONTH() returns an integer numeric value in the range of zero to 12.
     Specifying a null date (CTOD("")) returns zero.

 Description

     MONTH() is a date conversion function that is useful when you require a
     numeric month value during calculations for such things as periodic
     reports.  MONTH() is a member of a group of functions that return
     components of a date value as numeric values.  The group includes DAY()
     and YEAR() to return the day and year values as numerics.  CMONTH() is a
     related function that allows you to return the name of the month from a
     date value.

 Examples

     .  These examples return the month of the system date:

        ? DATE()                        // Result: 09/01/90
        ? MONTH(DATE())                 // Result: 9
        ? MONTH(DATE()) + 1             // Result: 10

     .  This example demonstrates MONTH() acting on a null date:

        #define NULL_DATE   (CTOD(""))
        ? MONTH(NULL_DATE)              // Result: 0

 Files   Library is CLIPPER.LIB.

See Also: CMONTH() DAY() DOW() YEAR()