Although the IBM i has had a date data type for a long time, many IBM i shops still use a numeric field to store dates in data files. Many use an eight-digit scheme (in the format yyyymmdd) that's pretty easy to work with in AVR for .NET. However, many others use a seven-digit scheme (in the format cyymmdd) where the first digit designates the century.
The seven-digit date scheme is heavily used by JBA financial applications and other 1990's era ERP apps. This date data type is pretty substantially constrained because it can only render dates with years that start with either 19 or 20. If you need to work dates from before the 20th century or after the 21st century, the seven-digit date isn't for you. This date type seems pretty silly today, but back in its day it was borderline revolutionary. After all, compared to the widely used mmddyy, six-digit date storage from back in the day it doubled the centuries your dates could represent!
Constrained or not, the seven-digit date rears its ugly head occasionally with AVR programmers. It provides a minor challenge because .NET doesn't provide built-in help with that conversion. This article provides two AVR functions to convert a seven-digit numeric date to and from a System.DataTime data type.
This article isn't suggesting that you convert your data files to move away from the seven-digit date (although, if you do there may be prudent reasons for doing so). Rather, this article provides functions you can use to, after having read seven-digit dates from storage, convert those dates to and from a System.DataTime type in your programs.
SevenDateToDate. Converts a seven-digit numeric date to a System.DateTime date.
DateToSevenDate. Converts a System.DateTime date to a seven-digit numeric date.
// otherwise if c = 0 then the century is 1900.
// An exception is thrown if the date doesn't convert successfully.
SevenDate = SourceDate.ToString("0000000") // Get seven-digit string.
c  = SevenDate.SubString(0, 1)  // Get century.
yy = SevenDate.SubString(1, 2)  // Get last two digits of year.
dd = SevenDate.SubString(5, 2)  // Get the day.
Convert the incoming seven-digit numeric date to a string. The "0000000" mask for ToString() ensures the potential leading zero is preserved.
In line 30 above, the variable yyyy is assigned 2000 if c equals 1 or yyyy is assigned 1900 otherwise. You can read more about AVR's conditional expressions in slides 8-23 in this ASNApalooza presentation.
With the four-digit year calculated a new System.DateTime is returned.
// if c = 0 then the century is 1900.
yy = DateIn.ToString("yy") // Get the last two digits of the year.
mm = DateIn.Month // Get the month.
dd = DateIn.Day // Get the day.
Ensure that the first two digits of the year of the System.DateTime argument are either 19 or 20. If not, an exception is thrown.
Get the two-digit date values for year, month, and day from the incoming date and calculate the century value.
Return the concatenated date values as the seven-digit value needed. Although this line concatenates a string from those values, AVR coerces this as the correct *Integer4 return type at runtime.
If you want to add a layer of sophistication to it all, wrap these two functions as static members of a utility class.