FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Excel and Date
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
Excel and Date
Posted: Sat Apr 18, 2009 04:09 AM

Excel identifies a date with a sequential number indicating the numbers of days lapsed from Enero1, 1900.
For example: 38835 = 4/28/2006 (this is in format MMDDYYYY)
Does exist a Harbour function or someone know how to convert the Excel sequential number in date?

George

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Excel and Date
Posted: Sat Apr 18, 2009 05:33 AM
Harbour ( Clipper ) also stores Dates as numbers in memory. Difference between OLE internal number for dates and clipper numbers is 2415019.

If you read Excel Date ( or from any other OLE source ) as number, you can derive clipper date by adding 2415019 and converting to Date.

Example:
Code (fw): Select all Collapse
dDate := CToD( "" ) + nExcelDateAsNumber + 2415019


I do not know why do you need to all this. We can straight away read date values from Excel. TOleAuto class adds this difference and converts to date.
Regards



G. N. Rao.

Hyderabad, India
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
Re: Excel and Date
Posted: Sat Apr 18, 2009 03:14 PM

Thanks nageswaragunupudi for answer my post.
The reason that I need this is that I am reading a CSV file (created from Excel) that has a date field in sequential number format.
I do not have the excel application, therefore, I need to convert the sequential number to date format.

Thanks

George

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Excel and Date
Posted: Sat Apr 18, 2009 05:26 PM
We can also simplify this code
Code (fw): Select all Collapse
dDate := STOD( '18991230' ) + nExcelDateAsNumber
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion