Thursday | 28 MAR 2024
[ previous ]
[ next ]

OCONV Dates

Title:
Date: 2023-05-31
Tags:  universe

UniVerse dates are the number of days since 31 DEC 1967. This means that the 0th day is Dec 31st 1967 and Day 1 is Jan 1 1968.

PRINT
PRINT OCONV(0,'D')
PRINT OCONV(1,'D')

The default way dates are displayed is DD MMM YYYY with the month being the 3 letter name.

The above code would therefore print:

31 DEC 1967
01 JAN 1968

Below are the various conversions passed to OCONV and what they output. The general rule is that you can manipulate all parts of the date through OCONV so you shouldn't need any string munging to get a date into a format.

Regular conversions:

D:                  31 DEC 1967
D:                  01 JAN 1968
D:                  31 MAY 2023

Changing the delimiters:

D/:                 05/31/2023
D-:                 05-31-2023
D*:                 05*31*2023

Changing the order of things:

D/:                 05/31/2023
D/YMD:              2023/5/31
D/YMD[4,2,2]:       2023/05/31

D/YDM:              2023/31/5
D/YDM[4,2,2]:       2023/31/05

Displaying the full name of days and months, you can control the number of characters as well:

D/YWAMD[4,,A]:      2023/WEDNESDAY/MAY/31
D/YWAMD[4,,A2]:     2023/WEDNESDAY/MA/31

Manipulating just the month:

DM:                 5
DM[2]:              05
DMA:                MAY

Manipulating just the day:

DD:                 31
DW:                 3
DWA:                WEDNESDAY

Manipulating just the year:

DY:                 2023
D2:                 31 MAY 23
D2/:                05/31/23

Get the current day out of 365:

DJ:                 151

The full program:

*
TODAY = DATE()
*
PADDING = 'L#20'
PRINT
PRINT 'D:' PADDING : OCONV(0,'D')
PRINT 'D:'  PADDING : OCONV(1,'D')
*
PRINT
PRINT 'D:'  PADDING : OCONV(TODAY,'D')
PRINT 'D/:'  PADDING : OCONV(TODAY,'D/')
PRINT 'D-:'  PADDING : OCONV(TODAY,'D-')
PRINT 'D*:'  PADDING : OCONV(TODAY,'D*')
*
PRINT
PRINT 'D/:'  PADDING : OCONV(TODAY,'D/')
PRINT 'D/YMD:'  PADDING : OCONV(TODAY,'D/YMD')
PRINT 'D/YMD[4,2,2]:'  PADDING : OCONV(TODAY,'D/YMD[4,2,2]')
*
PRINT
PRINT 'D/YDM:'  PADDING : OCONV(TODAY,'D/YDM')
PRINT 'D/YDM[4,2,2]:'  PADDING : OCONV(TODAY,'D/YDM[4,2,2]')
PRINT 'D/YWAMD[4,,A]:' PADDING  : OCONV(TODAY,'D/YWAMD[4,,A]')
PRINT 'D/YWAMD[4,,A2]:' PADDING  : OCONV(TODAY,'D/YWAMD[4,,A2]')
*
PRINT
PRINT 'DM:' PADDING  : OCONV(TODAY,'DM')
PRINT 'DM[2]:' PADDING  : OCONV(TODAY,'DM[2]')
PRINT 'DMA:' PADDING  : OCONV(TODAY,'DMA')
*
PRINT
PRINT 'DD:' PADDING  : OCONV(TODAY,'DD')
PRINT 'DW:' PADDING  : OCONV(TODAY,'DW')
PRINT 'DWA:' PADDING  : OCONV(TODAY,'DWA')
*
PRINT
PRINT 'DY:' PADDING  : OCONV(TODAY,'DY')
PRINT 'D2:' PADDING  : OCONV(TODAY,'D2')
PRINT 'D2/:' PADDING  : OCONV(TODAY,'D2/')
*
PRINT
PRINT 'DJ:' PADDING  : OCONV(TODAY,'DJ')
*