|
Hello,
In order to get the time details for an Rdb/VMS date field, you need to
redefine your Master File Description for the date fields to extract the
time details using a FOCUS supplied routine called CVTSTIME as follows:
FIELD=DATE_TIME, ALIAS=DATE_TIME, USAGE=A8, ACTUAL=A8 ,$
DEFINE DATE/A11 = CVTSTIME(1,DATE_TIME,DATE);
DEFINE TIME/A5 = CVTSTIME(2,DATE_TIME,DATE);
Unfortunately, the DATE details will now come out in DD-MMM-YYYY format
which is absolutely useless for sorting on. You can, of course, mess
around with this date field in your procedure and define/compute a
field in [YY]YYMMDD format based on it which *can* be used for sorting.
I have actually just written my own subroutine for an application I am
currently working on which returns date and time details for an Rdb/VMS
date field. The subroutine needs to be linked into the FOCUS FUSELIB
library (see the FOCUS User Written Subroutines book). By passing
various conversion type parameters, the routine will return different
information about the date field:
[DEFINE]/[COMPUTE]
AFIELD/format = MYPROG( conversion_type,
RDB_DATE_FIELD,
AFIELD );
where RDB_DATE_FIELD appears in the Master File Description as:
FIELD=RDB_DATE_FIELD, ALIAS=RDB_DATE_FIELD, USAGE=A8, ACTUAL=A8 ,$
and the following table shows the results you can obtain:
Conversion Format Description
Type
---------------------------------------------------------------------
0 A23 Returns the standard DEC date format of
DD-MMM-YYYY HH:MM:SS.CC
1 A8 Returns the date in YYYYMMDD format
A16 Returns the date in YYYYMMDDHHMMSSCC (NBS) format
2 A8 Returns the date in DDMMYYYY format
3 A4 Returns the time in HHMM format
A8 Returns the time in HHMMSSCC format
4 A9 Returns the day of the week for the date
5 A5 Returns the number of days since the start of
'VAX Time' on 17-NOV-1858
As an extra, by passing the integer '1' instead of the RDB_DATE_FIELD,
the routine returns the information, depending on the conversion type
specified, for the current system date.
If you are interested in the routine, then please mail me at
FUTURS::CARSED. If not, havve fun !!
Regards - David Carse
|
| Hi gang,
Just to add my two-penn'orth...
Release 6.1 (if you've got it) has added more options to the CVTSTIME
routine (although I can't remember having seen anything to this effect
in the 'New Features' manual). To see them just type
? FUSELIB CVTSTIME
at FOCUS prompt. So, you could use one variant for display (1) and another
for sorting (4).
By the way I claim the prize for spotting your deliberate mistake,
David...
>> DEFINE TIME/A5 = CVTSTIME(2,DATE_TIME,DATE)
should read
DEFINE TIME/A5 = CVTSTIME(2,DATE_TIME,TIME)
Regards,
Paul K ^^^^
|
|
RE: .2 Well spotted, Paul !
If you want to stick with a FOCUS supplied routine then here is the
description of the CVTSTIME routine for FOCUS V6.1 :
-----------------------------------------------------------------------------
*FUSELIB CVTSTIME
CVTSTIME converts the 64-bit DEC standard date and time fields into a
printable character string.
The syntax is:
CVTSTIME (number, infield, outfield)
where:
Parameter Format Description
========= ====== ===========
number Numeric The number, from 0 to 2, that corresponds to
the format of the "outfield":
0 = DD-MMM-YYYY HH:MM:SS
1 = DD-MMM-YYYY
2 = HH:MM:SS
3 = DD-MMM-YYYY HH:MM:SS:CC
4 = YYYY-MM-DD HH:MM:SS:CC
infield Alpha The field containing the 64-bit date/time string.
outfield Integer The name of the field containing the converted
date/time. Please note: "outfield" must have
the length required by the date/time format
needed by "number":
"number" Bytes
0 20
1 11
2 8
3 23
4 22
This parameter can also be the format of the
output value, enclosed in single quotation marks.
-----------------------------------------------------------------------------
Hope this helps - David
|