xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CMonth()

Returns the name of a month from a date.

Syntax

CMonth( <dDate> )  --> cMonthName

Arguments

<dDate>
This is an expression returning a value of data type Date.

Return

The function returns a character string holding the month name of <dDate>. When <dDate> is an empty date, the function returns a null string ("").

Description

The CMonth() function converts a date value into the name of the corresponding month. Use CDoW() to obtain the weekday name as character value. Both functions are used to format date values in a textual way.

Note:  xHarbour's national language support allows for returning the name of a month in various languages. Refer to HB_LangSelect() for selecting a language module.

Info

See also:CDoW(), Date(), Day(), DoW(), DtoC(), HB_LangSelect(), Month(), StoD(), Year()
Category: Conversion functions , Date and time
Source:rtl\datec.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example uses a user defined function to fill an array
// with all month names abbreviated to the first three letters.

   PROCEDURE Main
      LOCAL aMonths := MonthNames(3)

      // display all month names
      AEval( aMonths, {|c| QOut(c) } )
   RETURN

   FUNCTION MonthNames( nLen )
      LOCAL aArray[12]
      LOCAL i, cDate, cMonth

      FOR i:=1 TO 12
         cDate := "2000" + PadL( i, 2, "0" ) + "01"
         cMonth:= CMonth( StoD( cDate ) )

         IF Valtype( nLen ) == "N"
            aArray[i] := Left( cMonth, nLen )
         ELSE
            aArray[i] := cMonth
         ENDIF
      NEXT

   RETURN aArray

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe