Convert *timestmp to readable format

I need to convert one ADABAS field which has stored *timestmp in it,
I need to convert that to readable format(numeric). Can someone please help me on this.

Thanks
Kal

USR1023N (in SYSEXT) will convert it for you.

Hello Kal,

Natural’s documentation says: *TIMESTMP is an “Machine-internal store clock value”.

So this value could be different on different types of hardware.

On my Natural@Solaris, this value seems to stand for millonth of seconds since 1970-01-01 (if you ignore the rightmost 3 half-bytes - which are always zero).

Matthias

Good idea to search in SYSEXT. But it seems USR1023N is not available on Open Systems…

I have it in Nat6.3.7 under both Windows and Linux.

By the way, Id be very interested in knowing (perhaps, some SAG gurus might answer this) why *TIMESTMP display/manipulation is so hidden from those "mere mortals" (in our shop, for example, we (programmers) don't have access to SYSEXT at all since "its too dangerous" :slight_smile:

Well, I (only a self-described guru) must agree that certain user exits should/must be restricted from mere mortals - several immediately come to mind: terminating user CICS sessions, manipulating UDB or TF parameters. A simple solution is for your Natural Administrator to copy specific modules from SYSEXT to SYSTEM or a Steplib. It should be a simple matter to make your case for access to USR1023N, especially since it can do no harm.

I recommend a download of the Community Edition of Natural to your personal PC (at home) so that you can play with SYSEXT. As a Natural developer, you should know what facilities are available. Then you can speak intelligently when you request access to additional user exits that will make your life easier.

Thanks everyone. But our administrator is not ready to copy USR1023N. We tried it already.Is there any way other than using USR1023N.

Thanks
Kal

Ok, we’re still on Nat 6.1.1 … :oops:
But we will do an upgrade in September.

I believe there is no harm in copying cataloged version of USR1023N (Not sure if SAG provides source as well :lol: )

Discuss with your Admin about it’s restriction. Here is the code that invokes the routine:

DEFINE DATA
LOCAL
1 #FUNCTION       (A01)
1 #RET-CODE       (N04)
1 #VALUES
  2 #TIME         (T)
  2 #DATE         (D)
  2 #TIMESTMP     (B08)
  2 #MICRO-SEC    (P19)
1 #MSG            (A64)
END-DEFINE
SET KEY ALL
/*
MOVE *TIMX     TO #TIME
MOVE *DATX     TO #DATE
MOVE 'T'       TO #FUNCTION
/*
REPEAT
  /******************************************************
  INPUT WITH TEXT #MSG
    /   '*** Convert Time Variables ***' (I)
    //  'Function .........' #FUNCTION  (AD=MIT'_')
    /   '(T) .............T' #TIME      (AD=MI)
    /   '(D) .............D' #DATE      (AD=MI DF=L)
    /   '*TIMESTMP .......S' #TIMESTMP  (AD=MI)
    /   'Micro seconds ...M' #MICRO-SEC (AD=MIL)
  /******************************************************
  IF *PF-KEY NE 'ENTR'
    STOP
  END-IF
  /*
  RESET #MSG
  /*
  CALLNAT 'USR1023N' #FUNCTION #RET-CODE #VALUES
  /*
  DECIDE ON FIRST #RET-CODE
    /   '(T) .............T' #TIME      (AD=MI)
    /   '(D) .............D' #DATE      (AD=MI DF=L)
    /   '*TIMESTMP .......S' #TIMESTMP  (AD=MI)
    /   'Micro seconds ...M' #MICRO-SEC (AD=MIL)
  /******************************************************
  IF *PF-KEY NE 'ENTR'
    STOP
  END-IF
  /*
  RESET #MSG
  /*
  CALLNAT 'USR1023N' #FUNCTION #RET-CODE #VALUES
  /*
  DECIDE ON FIRST #RET-CODE
    VALUE 0   IGNORE
    NONE      COMPRESS 'Error:' #RET-CODE TO #MSG
  END-DECIDE
  /*
END-REPEAT
END

Thank you very much, guys.

I cant disagree less with " I believe there is no harm in copying cataloged version of USR1023N". Moreover, Id go even further: I personally convinced there is no harm in making this user-exit (why is it a user-exit, for Gods sake?!) available as a standard NATURAL feature. As for those (like our NATURAL sysadmins who will "assess a possibility to give that user-exit to us") Id say “May God judge them” :slight_smile:

The other way would be to do it all by yourself:

define data local
01 #t (T) init <D'1900-01-01'>  /* or whatever your epoch is
01 #b8   (B8)
01 redefine #b8
  02 #b2   (B2/4)
01 #p20  (P20)
01 #f8   (f8)
end-define
*
#b8 := *TIMESTMP
*
* interpret TIMESTMP as an unsigned integer
*
#p20:= #b2(1)   /* since natural only treats B2 or B1 as unsigned int.
#f8 := #p20* 65536 * 65536 * 65536
#p20:= #b2(2)
#f8 := #f8 + #p20 * 65536 * 65536
#p20:= #b2(3)
#f8 := #f8 + #p20 * 65536
#p20:= #b2(4)
#f8 := #f8 + #p20
*
* ignore the rightmost 12 bit, and millionth --> tenth
*
compute rounded #p20= #f8 / 256 / 16 / 100000
*
* add tenths of seconds to epoch
*
#t  := #t + #p20
*
display #t(EM=YYYY-MM-DD^HH:II) #b8 #f8 #p20 
end

Hello everyone,
Kal is being less than truthful with you. I happen to know that Kal has not asked his admin about copying USR1023N. Also, I know that USR1023N is already in the SYSTEM library on Kal’s system. I am not even sure why Kal is asking questions about NATURAL since he is supposed to be processing this field with a COBOL program. In fact, I am not sure that Kal is authorized to even attempt to log on to NATURAL.

Hi everybody,

Perhaps, it will be too much for such a small subject, but I personally liked MUCH BETTER “other way to do it” from Matthias than that Wayne`s “clarification”.
As for myself, I still have no access to that USER EXIT (would NOT pretend that I need it right now)
Just my 2 cents

By the way:

*TIMESTMP seems to be timezone-independent… i.e. GMT.

*TIMX is local time.

I agree that generally more people will find the information helpful on how to parse timestamps besides the USR routine, but I also empathise with the need to defend one’s self against libel.

I am sure the very helpful Matthias would post a retort if someone else posted that he ate babies for breakfast (I am sure he does not eat babies for breakfast - that was a rhetorical example).

Enough said on that.