Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

regional settings for long/short dates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zSplash - 10 Oct 2006 23:08 GMT
I have an addin that works great if regional settings (long/short dates) are
set appropriately.  How can I programmatically change these date formats to
be as needed?

TIA
(Word 2002 SP3)
Shauna Kelly - 10 Oct 2006 23:44 GMT
Hi zSplash

You can't. Or if you can you shouldn't. Or if you should, then your users
will quite rightly not use your software!

For example, if you changed the regional settings on one of my machines, my
accounting application would not work. I don't like the accounting system
much, but it's what I bought, so I'm stuck with it. And it only works for me
if my short date setting is yyyy-mm-dd. I hate to think what would happen if
it was open while I was running code that changed the regional settings.
Change them and you'll get sent to The Boardroom where Mr Trump will have
strong words to say<VBG>.

So, how to cope with dates if regional settings are different? My four rules
are:

- avoid ever getting an ambiguous date in the first place (that's why web
sites have drop-down fields for Day, Month and Year)

- if you're getting a date from a user, convert it to a Date and play it
back to the user instantly (eg if the user types 2/1/2006 in a text box,
convert that immediately to a date and display "2 January 2006" or "1
February 2006" in the text box, depending on what you think the user might
have meant)

- convert all dates to a Date type at the earliest opportunity,
disambiguating if necessary

- avoid date literals; use DateSerial; use DateValue with an unambiguous
string such as "2 Jan 2006"

By the way, there's a good chapter on International Issues in Excel 2002 VBA
by Stephen Bullen, John Green, Rob Bovey and Robert Rosenberg (Wrox, 2001).

If you have specific code you need help with, let us know.

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

>I have an addin that works great if regional settings (long/short dates)
>are set appropriately.  How can I programmatically change these date
>formats to be as needed?
>
> TIA
> (Word 2002 SP3)
zSplash - 11 Oct 2006 18:05 GMT
Thanks for the advice/explanation.

st.

> Hi zSplash
>
[quoted text clipped - 44 lines]
>> TIA
>> (Word 2002 SP3)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.