[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference ilbbak::ibi_focus

Title:FOCUS, from INFORMATION BUILDERS
Moderator:ZAYIUS::BROUILLETTE
Created:Thu Feb 19 1987
Last Modified:Mon May 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:615
Total number of notes:1779

459.0. "DEFINE FIELDS QUESTION" by PENUTS::WCOLBERT () Tue Sep 17 1991 17:08

    A master file has a field DATE_TIME usage YMD and ACTUAL=DATE.
    
    I need to be able to print DATE and TIME as two separate fields
    so I can sort on DATE and TIME.  The purpose is to report all
    activity at a specified TIME of day.  The RDB file does not separate
    DATE and TIME.  
    
    How can I define 2 fields?  1 field = first x
    characters and the second field = the last x characters of the data.
    
    example
    
    DATE/XXX = EDIT(DATE_TIME, 'XX-XXX-XXXX');
    TIME/XXX  =EDIT(DATE_TIME, 'XX:XX');
T.RTitleUserPersonal
Name
DateLines
459.1Help if you want it ?SHIPS::CARSE_DWed Sep 18 1991 07:1859
    
    
    
    
    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
459.2For what it's worth...RDGE44::KEEGAN_9Wed Sep 18 1991 07:4227
    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                                           ^^^^
459.3A little bit more...SHIPS::CARSE_DWed Sep 18 1991 10:5043
    
    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