View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
RoccoCoetzee RoccoCoetzee is offline
external usenet poster
 
Posts: 5
Default Retrieving short system date format in VBA

Hi Jacob

Thank you for replying so quickly.

This function will return a date value formatted in the short date format
E.g. (30/09/2009)

What Im looking for is something that would return the format as string
E.g. ("dd/mm/yyyy") or ("mm/dd/yyyy").

The reason why is because I have a form that gets text input from users and
then should compile the date from what was selected amongst a number of other
input.

The problem is that not all my users have the same locale settings thus the
date is being compiled incorrectly because of the date format.

I have fixed this before with one of my VS project and want to use the same
code only problem is that the line,
€śSystemShortDateFormat =
System.Globalization.CultureInfo.CurrentCulture.Da teTimeFormat.ShortDatePattern€ť does not work in VBA.

The value of SystemShortDateFormat would then be = "DD-MM-YYYY" or some
thing to that effect.

So Im looking for a function of some sort returning the pattern / format
E.g. ("dd/mm/yyyy)" or ("mm/dd/yyyy") as with the VS class.

--
Rocco Coetzee


"Jacob Skaria" wrote:

Try
Formatdatetime(date,vbShortDate)

If this post helps click Yes
---------------
Jacob Skaria


"RoccoCoetzee" wrote:

Hi

Can someone please help me retrieving the system short date format (I
presume its from local)

I have managed to do that from Visual Studio (VB) with the following line.

SystemShortDateFormat =
System.Globalization.CultureInfo.CurrentCulture.Da teTimeFormat.ShortDatePattern

How do I accomplish this in VBA?

--
Rocco Coetzee