Page 1 of 1

GetExcelRange and time

PostPosted: Mon Jan 15, 2018 5:15 pm
by Maurizio
Hello Rao ,

I use GetExcelRange to import from Excel .
When in Excel I have a column format time ex : 08:50:00
GetExcelRange returns 0.33

Thanks in anticipations

Re: GetExcelRange and time

PostPosted: Tue Jan 16, 2018 9:55 am
by Silvio.Falconi
do you tried to converte in text format ?

Re: GetExcelRange and time

PostPosted: Tue Jan 16, 2018 9:59 am
by Silvio.Falconi
I tried and run ok
Image

Re: GetExcelRange and time

PostPosted: Tue Jan 16, 2018 2:11 pm
by nageswaragunupudi
Mr Silvio

You stored the values in Excel in text format. So the same text values are read from the range and you do not see any difference. But storing Dates, DateTime values and Time valeus as Text in Excel is not the best practice because these values cannot be used for computations.

Mr. Maurizio has stored the time values in Time format.

Mr. Maurizio

Excel internally stores Dates, DateTime values and Time values as double precision numbers and displays in the required format after conversion.

So the time "08:50:00" is stored as a fraction of day, i.e., ( 8 * 3600 + 50 * 60 ) / 86400 = 0.3680555...
When our program reads the data from Excel, it reads the value as number. We need to convert it back to time format for storage or display in Harbour.
You can do this by
SECTOTIME( nValue * 24 * 3600 ) where nValue is the value read by our program.

Re: GetExcelRange and time

PostPosted: Tue Jan 16, 2018 3:04 pm
by Maurizio
Thank Rao ,
works perfectly :lol:

Maurizio
www.nipeservice.com