Convert Excel serial number date to VFP date

Excel stores dates as the number of days since 1900-01-00. The number 1 represents 1900-01-01 and so on. The time part, if present, is represented as decimal portion. There's a bug in implementation of that sequence. It assumes that there was 1900-02-29 but 1900 is not a leap year. As result the code below correctly convert dates starting with 1900-03-01 only.

For more info about Excel dates see How to use dates and times in Excel and Dates And Times In Excel.

This is sample code. Add error handling and adjust to your requirements as necessary.

&& Convert Excel serial number to date 
FUNCTION ExcelSerialNumber2Date(tnExcelSerialNumber)
RETURN {^1899/12/30} + tnExcelSerialNumber 
 
&&-----------------------------------------------
&& Example
? ExcelSerialNumber2Date(39278)			&& 2007-07-15

See Also Convert Unix time to datetime