Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default How to override windows settings for date?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default How to override windows settings for date?

Check Tools menu - Options. There may be a option to solve your problem.
Look under International. the US version I have may not have the same
options in your version.

"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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default How to override windows settings for date?

thanks Joel but as you had stated i dont have an option is there any other
way to do this

"Joel" wrote:

Check Tools menu - Options. There may be a option to solve your problem.
Look under International. the US version I have may not have the same
options in your version.

"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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 256
Default How to override windows settings for date?

Maybe something along these lines?

Public Sub mySub()
Dim tempDate As Date
Dim myDate As Date

If (Application.International(xlDateOrder) = 0) Then
' month comes first
myDate = Format(tempworksheet.Cells(1, 1).Value, "yyyy-mmm-
dd")
ElseIf (Application.International(xlDateOrder) = 1) Then
' day comes first
' switch month and day places
tempDate = DateSerial(Year(tempworksheet.Cells(1, 1).Value),
Month(tempworksheet.Cells(1, 1).Value), _
Day(tempworksheet.Cells(1, 1).Value))
myDate = DateSerial(Year(tempDate), Day(tempDate),
Month(tempDate))
ElseIf (Application.International(xlDateOrder) = 2) Then
' year comes first
End If

Debug.Print Format(myDate, "yyyy-mmm-dd")
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to override windows settings for date?

Maybe something along these lines?

Public Sub mySub()
Dim tempDate As Date
Dim myDate As Date

If (Application.International(xlDateOrder) = 0) Then
' month comes first
myDate = Format(tempworksheet.Cells(1, 1).Value, _
"yyyy-mmm-dd")
ElseIf (Application.International(xlDateOrder) = 1) Then
' day comes first
' switch month and day places
tempDate = DateSerial(Year(tempworksheet.Cells(1, 1).Value), _
Month(tempworksheet.Cells(1, 1).Value), _
Day(tempworksheet.Cells(1, 1).Value))
myDate = DateSerial(Year(tempDate), _
Day(tempDate), _
Month(tempDate))
ElseIf (Application.International(xlDateOrder) = 2) Then
' year comes first
' respond appropriately
End If

Debug.Print Format(myDate, "yyyy-mmm-dd")
End Sub



"Arun" wrote:

thanks Joel but as you had stated i dont have an option is there any other
way to do this

"Joel" wrote:

Check Tools menu - Options. There may be a option to solve your problem.
Look under International. the US version I have may not have the same
options in your version.

"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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Date Format - users should be able to override it automatic. jamezog Excel Discussion (Misc queries) 7 May 20th 10 02:45 PM
problem with excel page settings in office for osx and windows xp Craig Excel Discussion (Misc queries) 1 April 14th 05 08:34 AM
override locale computer settings n.almeida Excel Discussion (Misc queries) 3 February 18th 05 12:00 AM
override language settings on date n.almeida Excel Discussion (Misc queries) 0 February 15th 05 02:45 PM
How do I override fixed decimal place settings in EXcel 2003? jroyv Excel Worksheet Functions 2 February 11th 05 06:07 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"