×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PF format with data stamp

PF format with data stamp

PF format with data stamp

(OP)
I'm trying to create a Physical file through DDS (not SQL) that would stamp a field with the current date in the format YYYYMMDD and store it this way. I'm able to get the format with the dashes in between year, month and day with the DATFMT keyword but do not want it this way. Would like a field length of 8, not 10.
Does anyone know if this is possible?
Thanks.

RE: PF format with data stamp

Quote (George221):

Would like a field length of 8, not 10.
Does anyone know if this is possible?
Only if you store them as numeric, not as dates. But it does not matter. i5/OS stores dates internally as 4-byte binary. It just displays them as 10-character dates (with separators). In reality, you can, in your programs, display them any way you want.

When defining a date field, you must have a date separator:

DATSEP (Date Separator) keyword for physical and logical files

Quote (IBM DDS Manual):

For physical files, if you do not specify the DATSEP keyword, the default is the job attribute.

Solum potestis prohibere ignes silvarum.

RE: PF format with data stamp

(OP)
"Only if you store them as numeric"

Can you show an example of how the physical file would automatically generate a date stamp with a field like this?

RE: PF format with data stamp

It's the weekend and I don't have access to a machine right now, but you code it in DDS as a type L (date). If you don't specify a format with the DATFMT keyword, it will default to *ISO (2007-12-22).

Now, in RPG, if you want to display the date without the separators, you can do this:

       displaydate = %char(ddsdate:*iso0);

The zero means "don't use a separator".

But as I said, you cannot store a native date without a separator. But that should not concern you. Under the covers, it's a 4-byte binary integer.

What, exactly, are you trying to accomplish?

Solum potestis prohibere ignes silvarum.

RE: PF format with data stamp

(OP)
ok, I'll give this a try. Thanks.

RE: PF format with data stamp

George221,

Making a field as a date data type does not "stamp" the record with the current date like SQL does with the timestamp data type. If you don't move the date into the date field, it will default to 0001-01-01, the date's low value.


RE: PF format with data stamp

(OP)
Tcsbiz,
If I insert a record using SQL, it will automatically stamp that date field with the current date (without specifying a value or function for that field on the insert statment), now if I write that record using RPG, you are right, it defaults to 0001-01-01.
How should I define the DDS then to get this date field automatically populated when I write records through RPG?
Thanks.

RE: PF format with data stamp

Why not just do that in RPG?

TimeStampField = %timestamp();

Solum potestis prohibere ignes silvarum.

RE: PF format with data stamp

Quote (George221):

How should I define the DDS then to get this date field automatically populated when I write records through RPG?
You cant do it straight. To do so, you can utilize one of the options below :
- use SQL to create the date field as DATE NOT NULL WITH DEFAULT current date.
- populate the date field using the default %date() or %timestamp() function value in the RPG program.
- create the date field MyDate thru DDS (type L or Z) then give it the current date or current timestamp default value thru ALTER statement, that is

CODE

ALTER TABLE ... ALTER COLUMN MyDate SET DATA TYPE
DATE NOT NULL WITH DEFAULT current date
                      

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close