IBM Security Z Security

Security for Z

Join this online user group to communicate across Z Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Convert a numeric field to a Date

    Posted Tue December 02, 2025 02:05 PM
    Edited by Scott Lahner Wed December 03, 2025 01:27 PM

    I am using Carla to read an input file with two fields (A numeric field which is a date and a text field) see below.  I would like to select records based on the date and be able to use the TODAY keyword. But I am not having any luck converting the numeric field to a valid date.  

    Input File:

    20251202 RECORD12
    20251102 RECORD11
    20251002 RECORD10
    20250902 RECORD9 
    20250802 RECORD8 
    20250702 RECORD7 
    20250602 RECORD6 
    20250502 RECORD5 
    20250402 RECORD4 
    20250302 RECORD3 
    20250202 RECORD2 
    20250102 RECORD1 

    I am trying to convert the numeric field to a date using Carla

    deftype type=$input                           
    alloc   type=$input  dd=INPUT                 
     newlist type=$INPUT DD=OUTREC                
     def date8(date,8,'Date8') as ,               
     convert(substr(record,1,8),datetime,date)    
     def date10($date,10,'Date10') as ,           
     convert(substr(record,1,8),datetime,date)    
     def mydate(8,'MyDate') as substr(record,1,8) 
     def text(8,'MyRecord') as substr(record,10,8)
      select date8<today-30                          
     sortlist,                                    
      date8 date10 mydate text  

    Output file: Note the dates should be for example 02Jan25 and 2025-01-02 but they are converting to Jan 10th 2025.

    Date8    Date10     MyDate   MyRecord  
    10Jan25  2025-01-10 20250102 RECORD1   
    20Jan25  2025-01-20 20250202 RECORD2   
    30Jan25  2025-01-30 20250302 RECORD3   
     9Feb25  2025-02-09 20250402 RECORD4   
    19Feb25  2025-02-19 20250502 RECORD5   
     1Mar25  2025-03-01 20250602 RECORD6   
    11Mar25  2025-03-11 20250702 RECORD7   
    21Mar25  2025-03-21 20250802 RECORD8   
    31Mar25  2025-03-31 20250902 RECORD9   
    10Apr25  2025-04-10 20251002 RECORD10  
    20Apr25  2025-04-20 20251102 RECORD11  
    30Apr25  2025-04-30 20251202 RECORD12                   

    Also is there a way to convert a Carla date to this format YYYYMMDD without / or - ?

    For Example, 22Apr25 convert to 20250422

    Thanks Rob, yes I did try adding dashes, slashes and spaces in between the Year/Month/Day and that does resolve the dates. 

    However I was wondering is there a way I could identify records older than 90 days without converting MyDate (YYYYMMDD) to a date?  I tried a couple of things:

    I passed a symbolic jcl value to the carla step and called it THRESH.  I then created these Carla statements but it didn't produce any records

    SYMBOLIC num thresh=&thresh  <-- In the sysprint this does resolve SYMBOLIC num thresh=20251203 

    and then I added a select statement,  select mydate<thresh-90, but it didn't identify any records. So this didn't work. 

     So then I just tried a select statement referencing the jcl symbolic value: select mydate<&thresh-90.  And in the sysrpint it shows it did resolve the value "select mydate<20251203-90" but I received CKR0412 12 String longer than expected size 10 at SYSIN line 14.  

    Is there a way I could pass today's date as a jcl symbolic value and then use it to do math with in the carla step (e.g. mydate<&thresh-90)?



    ------------------------------
    Scott Lahner
    ------------------------------



  • 2.  RE: Convert a numeric field to a Date

    Posted Wed December 03, 2025 04:17 AM
    Edited by Rob van Hoboken Wed December 03, 2025 04:19 AM

    Hi Scott

    The manual shows a sample datetime input format as 11 Nov 2019 13:10:00.  But when I look at the day and month values in your DATE8 and DATE10 columns, I suspect that the input format interprets your 8 digit date as a JULIAN date: 20251202 -> 2025.120 -> April 30, 2025, and it ignores the 8th character.

    If you could massage the format of your data set, can you insert dashes between the year, month and day parts?

    > Also is there a way to convert a Carla date to this format YYYYMMDD without / or - ?

    This request has been made more times than I can count, and never made it to the development list.  Feel free to open an Idea but also check how many Ideas there are already that don't get implemented.  Anyway, you could look at composing the date from 3 parts like

    sortlist date10(year) | date10(usdate,2) | date10(eudate,2)

    Horribly inefficient because the date is calculated and converted 3 times, but hey, it may get you what you need.  Here is a sample of date output strings

    ------------------------------
    Rob van Hoboken
    ------------------------------



  • 3.  RE: Convert a numeric field to a Date

    Posted Thu December 04, 2025 10:25 AM

    Thanks Rob, yes I did try adding dashes, slashes and spaces in between the Year/Month/Day and each will resolve the dates. 

    However I was wondering is there a way I could identify records older than 90 days without converting MyDate (YYYYMMDD) to a date?  I tried a couple of things:

    I passed a symbolic jcl value to the carla step and called it THRESH.  I then created these Carla statements but it didn't produce any records, 

    SYMBOLIC num thresh=&thresh  <-- In the sysprint this does resolve SYMBOLIC num thresh=20251203 

    Select mydate<thresh-90 <- but it didn't identify any records. So this didn't work. 

     So then I tried a select statement referencing the jcl symbolic value:

    select mydate<&thresh-90.  And in the sysrpint it shows it did resolve the value "select mydate<20251203-90" but I received CKR0412 12 String longer than expected size 10 at SYSIN line 14.  

    Is there a way I could pass today's date as a jcl symbolic value and then use it to do math with in the carla step (e.g. mydate<&thresh-90)?



    ------------------------------
    Scott Lahner
    ------------------------------



  • 4.  RE: Convert a numeric field to a Date

    Posted Thu December 04, 2025 11:25 AM

    Hi Scott,

    CARLa does not have arithmetic operators, with one exception, you can calculate relative dates using TODAY-nn and DUMPDATE-nn.  See here.  The manual states that the left part of the condition must be a date field.

    SYMBOLIC was made with one purpose in mind, and that is replacing the text string by some digits.  Not an expression.

    You have 2 options:

    1. pass the actual threshold value by JCL, so today is December 3rd, 90 days ago was at or around September 5th, so
      // SET CUTOFF=20250905
      //SYSIN DD *,SYMBOLS=JCLONLY
      ...
      select mydate<&cutoff
    2. you can generate the SELECT statement in a Rexx program that you execute before the C2RC proc, write a NEWLIST block into a data set:
      /* Rexx */
      queue 'newlist type=$input outlim=0 name=cutoff'
      queue 'select mydate<' || date('S', date('B')-90, 'B')
      Allocate this data set to file CUTOFF of your C2RC, use INCLUDE DD=CUTOFF to load this CARLa block.
      Refer to the result of the newlist with SELECT xxxxxx LIKELIST=CUTOFF


    ------------------------------
    Rob van Hoboken
    ------------------------------



  • 5.  RE: Convert a numeric field to a Date

    Posted Thu December 04, 2025 11:52 AM

    Thanks for the help Rob.



    ------------------------------
    Scott Lahner
    ------------------------------