PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

check date format in regional setting

 
 
Prema
Guest
Posts: n/a
 
      19th Aug 2009
I am using Office 2007. I created a macro to be used by many users and it
strips part of the date to be used for file saving. Users have different date
format in their Windows Regional settings.

Are there any vb code I can use to check Regional date format of the pc
running the macro?

In my macro users select a Sunday date from dropdown list and I entered a
formula in next cell to add 1 to it to get Monday date. I then use Monday
date to get YYYY, MM and DD to make up value YYYYMMDD to use in file name.

Example
B2 and B3 are formatted as Date 2001-03-14
B2 selected value - 2009-08-16
B3 calculated value - 2009-08-17
I would like file name date value to be 20090817
I am using file_name_date = LEFT(B3,4) & MID(B3,6,2) & RIGHT(B3,2)

This works OK if short date in Windows is set to yyy-mm-dd but not if it is
dd/mm/yyyy.

Any suggestions would be most appreciated.

Prema
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      19th Aug 2009
Hi

In VBA use the format function:

file_name_date = Format(Range("B3").Value, "yyyymmdd")

Regards,
Per

On 19 Aug., 23:26, Prema <Pr...@discussions.microsoft.com> wrote:
> I am using Office 2007. I created a macro to be used by many users and it
> strips part of the date to be used for file saving. Users have different date
> format in their Windows Regional settings.
>
> Are there any vb code I can use to check Regional date format of the pc
> running the macro?
>
> In my macro users select a Sunday date from dropdown list and I entered a
> formula in next cell to add 1 to it to get Monday date. I then use Monday
> date to get YYYY, MM and DD to make up value YYYYMMDD to use in file name.
>
> Example
> B2 and B3 are formatted as Date 2001-03-14
> B2 selected value - 2009-08-16
> B3 calculated value - 2009-08-17
> I would like file name date value to be 20090817
> I am using file_name_date = LEFT(B3,4) & MID(B3,6,2) & RIGHT(B3,2)
>
> This works OK if short date in Windows is set to yyy-mm-dd but not if it is
> dd/mm/yyyy.
>
> Any suggestions would be most appreciated.
>
> Prema


 
Reply With Quote
 
Prema
Guest
Posts: n/a
 
      20th Aug 2009
Thank you for your help. Your solution works well.
Prema

"Per Jessen" wrote:

> Hi
>
> In VBA use the format function:
>
> file_name_date = Format(Range("B3").Value, "yyyymmdd")
>
> Regards,
> Per
>
> On 19 Aug., 23:26, Prema <Pr...@discussions.microsoft.com> wrote:
> > I am using Office 2007. I created a macro to be used by many users and it
> > strips part of the date to be used for file saving. Users have different date
> > format in their Windows Regional settings.
> >
> > Are there any vb code I can use to check Regional date format of the pc
> > running the macro?
> >
> > In my macro users select a Sunday date from dropdown list and I entered a
> > formula in next cell to add 1 to it to get Monday date. I then use Monday
> > date to get YYYY, MM and DD to make up value YYYYMMDD to use in file name.
> >
> > Example
> > B2 and B3 are formatted as Date 2001-03-14
> > B2 selected value - 2009-08-16
> > B3 calculated value - 2009-08-17
> > I would like file name date value to be 20090817
> > I am using file_name_date = LEFT(B3,4) & MID(B3,6,2) & RIGHT(B3,2)
> >
> > This works OK if short date in Windows is set to yyy-mm-dd but not if it is
> > dd/mm/yyyy.
> >
> > Any suggestions would be most appreciated.
> >
> > Prema

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
date - regional setting sigava77 via AccessMonster.com Microsoft Access Form Coding 1 16th Nov 2007 09:43 AM
Date format question - Regional Setting? =?Utf-8?B?R2FyeSBEb2xsaXZlcg==?= Microsoft Access Form Coding 10 9th Jun 2007 01:52 AM
Group policy to manage 'short date' setting under regional setting =?Utf-8?B?Sy5W?= Microsoft Windows 2000 Group Policy 4 6th May 2006 04:04 PM
Re: Setting date format, regional settings for ASP.NET Phil Winstanley [Microsoft MVP ASP.NET] Microsoft ASP .NET 0 15th Jun 2004 09:15 AM
Setting date format, regional settings for ASP.NET =?Utf-8?B?RGF2aWQgTGVlIEFV?= Microsoft ASP .NET 0 15th Jun 2004 03:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:49 PM.