Description

Converts a date, stored in internal system format, into a specified output format.

Syntax

output = OConv (expression, "D [year] [char] [E] [F] [G] [H] [I] [J] [Q] [W] [WA] [month_format] )

Parameters

OConv (D) accepts arguments for the following parameters.

ParameterDescription
expressionMust either be an integer value or an expression that yields an integer value.
DIndicates a date conversion.
- or - 
DXDX is used for international default conversions. Requires that a language is set in the environment, in field 15 (@environ.set<ENV_LND_DEFAULT$> ), eg LND_GERMAN_D, LND_FRENCH_F, etc., etc., etc. The language needs to be set within the SYSENV record prior to start.
yearIndicates the number of digits in the year. The range of valid values is 0-9. A 0 (zero) indicates that no year is output. The default value is 4. If you specify a value greater than 4, the year is prefixed with 0s.
charIdentifies the character that separates the month, day, and year. The default is a space. If you use the char option, the month is output as a two-digit number. Otherwise, the month is output as the corresponding month abbreviation in the default language set.
E, F, G, H, I, J, Q, W, WAThe E, F, G, H, I, and J options determine the order in which the day, month, and year are output. The default value is E, if no separator character (char) is specified, and H, if a separator character is specified.

The Q option will return the number of the quarter in which the date falls.

The W option will return the number of the day of the week. Sunday is 7.

The WA option will return the name of the day of the week.

Note: The Q, W and WA options are available beginning with OpenInsight version 7.2

OptionFormat
DE01 MAR 2009
DFMAR 2009 01
DG2009 01 MAR
DHMAR 01 2009
DI01 2009 MAR
DJ2009 MAR 01
DQ1
DW7
DWASunday
+If you enter the date in numbers, make sure you enter the date and month in the correct order for the option. For option "DE," 3/1/09 converts to 15036, while 1/3/09 converts to 14979.

If you do not specify an option, and if you enter dates as numbers, option H is assumed.

month_formatAllows you to specify how completely the date is displayed. Short month format ("S") uses only numbers for the month. Medium month format ("M") uses an abbreviated month name, and long month format ("L") displays the complete month name. The month name is taken from the default language set.

If you specify a separator character char, the default for month_format is "S." If you do not specify a separator character, the default for month_format is "M."

month_format also determines where the separator character char is placed in the date. For month_format "S", the separator character appears between all parts of the date. For month_format "M" or "L", the character appears immediately after the day, unless the day is the last part of the date (conversions F and J).

The following table demonstrates the effects of month_format. In each case, expression is 15036:

month_formatExample conversionOutput
None"D4/H"03/01/2009
S"D4/HS"03/01/2009
M"D4,HM"MAR 01, 2009
L"D4,HL"March 01, 2009

Remarks

OpenInsight saves all dates as the number of days before or after December 31, 1967. This date is saved as day 0 (zero).

Any date after December 31, 1967, is saved as a positive number, the number of days that have elapsed since that date. Any date before December 31, 1967, is saved as a negative number, the number of days backward from that date.

See also

Date()IConv Date (D), and TimeDate().

Example

* Assigns the value 03/01/09 to Date.
 
INTERNAL_DATE = 15036
Conversion  = "D2/"
Date     = OConv(INTERNAL_DATE, Conversion)
The following table provides examples of the correct use of the OConv Date function:
ExampleOutput
OConv(15036, "D")01 MAR 2009
OConv(15036, "D2")01 MAR 09
OConv(15036, "D4")01 MAR 2009
OConv(15036, "D/")03/01/2009
OConv(15036, "D2/")03/01/09
OConv(15036, "D*")03*01*2009
OConv(15036, "D/E")01/03/2009
OConv(15036, "D2E")01 MAR 09
OConv(15036, "D2/E")01/03/09
OConv(15036, "DS")01 03 2009
OConv(15036, "D/S")03/01/2009
OConv(15036, "DM")01 MAR 2009
OConv(15036, "D,M")MAR 01,2009
OConv(15036, "DL")01 March 2009
OConv(15036, "D,L")March 01,2009
OConv(15036, "DJL")2009 March 01
OConv(15036, "D4.EM")01.MAR 2009
OConv(15036, "D2.EL")01.March 09
OConv(15036, "DQ")1
OConv(15036, "DW")7
OConv(15036, "DWA")Sunday
When the language is set to LND_FRENCH_F, the following is observed
* if date() returns January 7, 2004 US then aa will contain 07.01.2005
aa = Oconv(date(), 'DX')
  • No labels