On Fri, 26 Apr 2019 11:57:49 -0400, Billy Ashton wrote:

>Hi all! I am trying to generate some data records using DFSORT based on a
>previous discussion here, and want to generate random date fields in
>YYYYMMDD format.
>
>I have specific years that need to be in the data (2015 and 2016), but
>there can also be other years as well. I think I can do this by specifying
>BUILD=(...,
>              C'201',
>              SEQNUM,1,ZD,START=0,INCR=1,
>              ...)
>
>To get me a range of records from 2010 through 2019, but how can I generate
>random MMDD values?
>
>Also if you have any other ideas for generating random dates (YYYYMMDD)
>overall, I would welcome your thoughts!

In Rexx:

/* Rexx
   Doc: Generate X random dates in years Y through Z
*/
trace R
parse arg X Y Z
First = date( 'Base', Y'0101', 'Standard' ) 
Last  = date( 'Base', Z'1231', 'Standard' )
Span = Last - First
trace N
say '' Span ,
    date( 'Standard', First, 'Base' ) ,
    date( 'Standard', First + Span, 'Base' )

do I = 1 to X
    say date( 'Standard', First + random( 0, Span ), 'Base' )
    end

Mr. Natural sez, Use the right tool for the job.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to