|
Hello,
I have one more issue with the POI sql2xls programs. I was trying to save an employee's hire date into a date data type field
in a physical file and then move that date into the excel sheet the POI
program creates. It doesn't seem to do what I want it to do (of course).
P date2xls B EXPORT
D date2xls PI 8F
D peDate D value D wwStrDate s d inz(d'1900-01-01')
D wwDays s 8F ** Dates in Excel are simply double-precision floating point
** numbers that represent the number of days since Jan 1, 1900
** with a few quirks:
** 1) Jan 1st 1900 is considered day #1, not 0.
** 2) 1900 is counted as a leap year (despite that it wasn't)
** 3) Any fraction is considered a time of day. For example,
** 1.5 would be noon on Jan 1st, 1900.
**/free
wwDays = %diff(peDate: wwStrDate: *DAYS) + 1;
// Excel incorrectly thinks that 1900-02-29 is
// a valid date. if (peDate > d'1900-02-28');
wwDays = wwDays + 1;
endif; return wwDays;
/end-freeP E
In my case, I like to have MM/DD/YY dates, so I use the following code:
Dates = HSSFWorkbook_createCellStyle(book);
DataFmt = HSSFWorkbook_createDataFormat(book);
TempStr = new_String('m/d/yy');
DateFmt = HSSFDataFormat_getFormat(DataFmt: TempStr);
HSSFCellStyle_setDataFormat(Dates: DateFmt);As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.