Entering Date Correctly in Excel

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
winstein
Pro Scripter
Posts: 84
Joined: Mon Nov 26, 2012 3:44 pm

Entering Date Correctly in Excel

Post by winstein » Tue Feb 16, 2016 11:55 am

When I used the XLSetCell function to enter a date, if that Day and Month are both 12 or less, the system has a tendency to interpret my dates as Month/Day/Year format instead of the Day/Month/Year format. This is in spite of cell format being in the D/M/Y format. Here's a sample code (make sure the first cell in Excel is set to D/M/Y format first):

Code: Select all

XLOpen>[[Insert Excel file here]],1,xlBook
XLSetCell>XLBook,Sheet1,1,1,10/2/2016,Result_Var
How do you guarantee that the date is in the Day/Month/Year format when both the Day and Month are 12 or less?

Thanks for reading.
PPQ

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Entering Date Correctly in Excel

Post by JRL » Thu Feb 18, 2016 2:48 pm

I have no experience with this but it appears to me that excel wants the date input as M/D/Y then will reconstruct it according to the cell's formatting.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts