Article 170885 of comp.os.vms:
Rob Gray wrote:
> 
> Is there a VMS routine that will allow an internal quadword date to be
> stored in a format that will allow the date and time to be sorted as part
> of an RMS string key.
> 

I'm not sure if this answers your question, but you can use
lib$format_date_time to convert the date to any format you want.
(See C example below)
See the library routines manual for more explanations on the date
formats.

#include <stdio.h>

#include <descrip.h>
#include <lib$routines.h>
#include <libdef.h>
#include <libdtdef.h>
#include <ssdef.h>

#define INIT_DESCR_FROM_CSTR(d,c_string) \
   (d.dsc$w_length = strlen (c_string), d.dsc$b_dtype =  DSC$K_DTYPE_T,
\
    d.dsc$b_class = DSC$K_CLASS_S, d.dsc$a_pointer = (c_string))


/* vax date is a pointer to a QUADWORD containing a VAX date in binary
form.
 * The function below converts the date to an ASCII date */
void cvt_date (void *vaxdate)
{
   static int first_call = 1 ;
   static unsigned long int dt_ctx ;

   char date_format[] = "|!Y4!MN0!D0|!H04!M0!S0!C2|" ;
   char converted_date[17 + 1] ;
   unsigned long int lib_sts, out_format = LIB$K_OUTPUT_FORMAT ;
   struct dsc$descriptor fmt, cvt ;

  /* set up date context for date conversion. You only need to do this
once. */
   if (first_call)
   {
      INIT_DESCR_FROM_CSTR(fmt,date_format) ;
      lib_sts = lib$init_date_time_context (&dt_ctx, &out_format, &fmt)
;
      if (lib_sts == SS$_NORMAL)
         first_call = 0 ;
   }

  /* convert to ASCII format */
   if (!first_call)
   {
      INIT_DESCR_FROM_ARR(cvt,converted_date) ;
      lib_sts = lib$format_date_time (&cvt, vaxdate, &dt_ctx, NULL,
NULL) ;
      if (lib_sts == SS$_NORMAL)
         printf ("Date: %.*s\n", (int) (sizeof converted_date - 1),
                 converted_date) ;
   }
}

-- 
 ___                                                               ___
(___)=============================================================(___)
|   | Jacques Raymond Kilchoer           MIS:Applications Support |   |
|   | Assistant DBA               /^\  ^     (714) 729-4500 x3733 |   |
|   | Cost Care, Inc.       /\  _/   \/ \            fax 729-4651 |   |
|   | Newport Beach   /\ /\/  \//     \  \_/\                     |   |
|   | CA 92660       /  \ /    /       \ /   \   Suisse/Schweizer |   |
|___|           ____/____\____/_________\___ _\_______   Svizzero |___|
(___)=============================================================(___)


