Null Date in PeopleCode

Just the other day, I needed to set a Date to null or blank, and I couldn’t remember how to do it.  Here’s my notes so that I can remember next time.  Javier’s blog came to the rescue:

Javier’s PeopleSoft blog: Setting Date Variables to Null in PeopleCode

The short version is: use the Date(0) function:

     Local Date &hireDate;

     &hireDate = Date(0);

Here’s some more information to explore a little more in depth…

The Date() function is designed to convert a numeric date into a date value.  Here’s PeopleBooks description:

The Date function takes a number in the form YYYYMMDD and returns a corresponding Date value. If the date is invalid, Date displays an error message.

A better example of that function might be:

     &hireDate = Date(19970713);

It does say that passing an invalid date throws an error, but apparently it will accept 0 and convert it to a null.

If you try to use null, you will get an error message. For example, this PeopleCode:

     Local Date &hireDate;

     &hireDate = Null;

You will get this error:

Assignment left hand side of type Date is not compatible with right hand side of type Object. (2,47)

Date Error Message

If this were SQL, we could use the %DateNull Meta-SQL message.  That might look something like this:

     SET NEW_EFFDT = %DateNull


Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.