Sign in to follow this  
Followers 0
tobject

_ExcelNumberFormat "YYYY-MM-DD"

5 posts in this topic

I'm getting back "20100804000000" instead of "2010-08-04"

anyonee knows why?

$oSheet = $oExcel.Worksheets.Item(1);

$ReportMaxRows = $oSheet.UsedRange.Rows.Count;

_ExcelNumberFormat($oExcel, "YYYY-MM-DD",1, 3, $ReportMaxRows,3);

for $iNdx= 1 to $ReportMaxRows

$Company=$oExcel.Activesheet.Cells($iNdx, 1).Value;

$Time=$oExcel.Activesheet.Cells($iNdx, 2).Value;

$Date =$oExcel.Activesheet.Cells($iNdx, 3).Value;

MsgBox(0,"sdsdsd",$Date );

Share this post


Link to post
Share on other sites



That's the way Excel stores date/time. Use .Text instead of .Value to get the text representing that value.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I think I met the same problem.But After I changed the format to the String, I got another string rather than 20100804000000.When I write it to a Excel cell, it has not turned back.Why?

How can I get "2010-08-04"?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I think I met the same problem.But After I changed the format to the String, I got another string rather than 20100804000000.When I write it to a Excel cell, it has not turned back.Why?

How can I get "2010-08-04"?

beantang - Welcome to this forum.

This is an old post and you'd be better off starting a new post with your own example script.

The solution that PsaltyDS gave is working.

Else you can use this to just convert it:

$Date = "20100804000000"
$Date = StringLeft($Date, 4) & "-" & StringMid($Date, 5, 2) & "-" & StringMid($Date, 7, 2)
MsgBox(0, '', $Date, 2)
Edited by JoHanatCent

Share this post


Link to post
Share on other sites

Thanks.I'd like to do that.

But before I start a new post, can you tell me why could I get the special string?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0