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 19 hours ago

    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



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


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

    Posted 5 hours ago
    Edited by Rob van Hoboken 5 hours ago

    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
    ------------------------------