× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have a data structure I use for timestamps for purposes like this.
The year validation should be pretty easy. It just has to be greater
than 0.

There is no easier way really. I prefer this data structure way only
because to me it feels less messy. To others, it may seem overkill.
It's a little more verbose, but it's just my preference.

* Time format DS
D timeStruct_t DS qualified
* based(template)
D timestamp 26a
D year 4s 0 overlay(timestamp) inz(1940)
D yearSep 1a overlay(timestamp : *next) inz('-')
D month 2s 0 overlay(timestamp : *next) inz(01)
D monthSep 1a overlay(timestamp : *next) inz('-')
D day 2s 0 overlay(timestamp : *next) inz(01)
D daySep 1a overlay(timestamp : *next) inz('-')
D hours 2s 0 overlay(timestamp : *next) inz(0)
D hourSep 1a overlay(timestamp : *next) inz('.')
D minutes 2s 0 overlay(timestamp : *next) inz(0)
D minuteSep 1a overlay(timestamp : *next) inz('.')
D seconds 2s 0 overlay(timestamp : *next) inz(0)
D secondSep 1a overlay(timestamp : *next) inz('.')
D milliseconds 6s 0 overlay(timestamp : *next) inz(0)

With the data structure above you could do something like this
assuming the DS name is timeStruct.

if (yearPassed > 0);
reset timeStruct;
timeStruct.year = yearPassed;
myDate = %date(%timestamp(timeStruct));
else;
// Handle the exception
endif;
--
James R. Perkins



On Fri, Mar 12, 2010 at 05:22, David FOXWELL <David.FOXWELL@xxxxxxxxx> wrote:
Hi,

I need the first day of the year which will be passed a string of length 4.
I think this will work :

MyDate = %DATE ( '01.01.' + yearPassed : *EUR );

But I will still need to test in case yearPassed isn't right.

Is there an easier way or less messy one?

Thanks
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.