Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel VBA Date format problem
Message
From
09/06/2014 05:30:59
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
09/06/2014 04:40:10
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP3
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01601467
Message ID:
01601474
Views:
31
>Hi,
>Thank you for your reply,
>but the result still the same.
>
>Is it Excel bug ?

Nope, it's a feature. You may set date in your app any way you want, but Excel has its own expectations about the date format, which mostly means it will read the user's system-level settings and expect dates to be set that way.

Since excel keeps dates as numbers - http://support.microsoft.com/kb/214094 calls them serial numbers. So you could use that:
oExcel = CREATEOBJECT([Excel.Application])
oExcel.SheetsInNewWorkbook = 4
oWorkbook = oExcel.Workbooks.Add()
nrow=2
dateZero=date(1899,12,31)
select invoice
do while !eof()
    with oExcel.activesheet
         .Range("A"+TRIM(PADR(nrow,11))).value=invoice->invno
         .Range("B"+TRIM(PADR(nrow,11))).NumberFormatLocal ='dd mmm yyyy' 	    
         .Range("B"+TRIM(PADR(nrow,11))).value=invoice->invdate - dateZero
   endwith 
   nrow = nrow + 1
   select invoice
   skip 1
enddo
Don't have excel installed (LibreOffice works just fine, thanks) so can't really try this.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform