ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   how to over write Windows Date format? (https://www.excelbanter.com/excel-discussion-misc-queries/145050-how-over-write-windows-date-format.html)

Arun

how to over write Windows Date format?
 
Hi guys,
i had written a macro to get a date value and convert it to the date format
which i need using the below code.
date = Format(tempworksheet.Cells(1, 1).Value, "yyyy-mmm-dd").

it is getting converted fine when the regional language is US(English).When
i change the language to czech it is not getting converted fine.The month is
taken as date and date as month i.e if i enter 06/05/2007 when in US gives
05-JUN-2007 but when in czech gives 06-MAY-2007 also i am not getting the MAY
in english it is coming in czech. I would like to know if there is some code
to override windows settings.Please help me by repling fast.

Regards,
Arun

Dave Peterson

how to over write Windows Date format?
 
If you manually format the cell (in excel, not vba) to an unambiguous date
format like yyyy-mmm-dd, what do you see?

I'm guessing that your code worked fine--but the date wasn't really what you
thought.

If that was a badddddd guess, then what happens with:

Dim myDate as string
mydate = Format(tempworksheet.Cells(1, 1).Value2, "yyyy-mmm-dd")

(I wouldn't use Date as a variable name, either.)

Arun wrote:

Hi guys,
i had written a macro to get a date value and convert it to the date format
which i need using the below code.
date = Format(tempworksheet.Cells(1, 1).Value, "yyyy-mmm-dd").

it is getting converted fine when the regional language is US(English).When
i change the language to czech it is not getting converted fine.The month is
taken as date and date as month i.e if i enter 06/05/2007 when in US gives
05-JUN-2007 but when in czech gives 06-MAY-2007 also i am not getting the MAY
in english it is coming in czech. I would like to know if there is some code
to override windows settings.Please help me by repling fast.

Regards,
Arun


--

Dave Peterson

Dave Peterson

how to over write Windows Date format?
 
If you formatted the cell manually and it showed the same result, then your date
in that cell isn't what you think it is.



Arun wrote:

Hi Peterson,
that gives the same result.date is just an example i had assigned it to a
cell directly which is of text format.Could u give some other
solution..Thanks

"Dave Peterson" wrote:

If you manually format the cell (in excel, not vba) to an unambiguous date
format like yyyy-mmm-dd, what do you see?

I'm guessing that your code worked fine--but the date wasn't really what you
thought.

If that was a badddddd guess, then what happens with:

Dim myDate as string
mydate = Format(tempworksheet.Cells(1, 1).Value2, "yyyy-mmm-dd")

(I wouldn't use Date as a variable name, either.)

Arun wrote:

Hi guys,
i had written a macro to get a date value and convert it to the date format
which i need using the below code.
date = Format(tempworksheet.Cells(1, 1).Value, "yyyy-mmm-dd").

it is getting converted fine when the regional language is US(English).When
i change the language to czech it is not getting converted fine.The month is
taken as date and date as month i.e if i enter 06/05/2007 when in US gives
05-JUN-2007 but when in czech gives 06-MAY-2007 also i am not getting the MAY
in english it is coming in czech. I would like to know if there is some code
to override windows settings.Please help me by repling fast.

Regards,
Arun


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 12:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com