PC Review


Reply
Thread Tools Rate Thread

date format change when opening file with vb

 
 
=?Utf-8?B?YnJhZGFzbGV5?=
Guest
Posts: n/a
 
      20th Feb 2007
When opening a file by simply double clicking, the dates in the file remain
in UK format.

When opening the file as part of a macro, the dates where the the day is
greater than 12 switches to US format.

Does anyone know how I can stop the dates switching to US format?

Thanks

David
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      20th Feb 2007
When you say switches, do you mean in shows in US format in Excel, or you
see US dates in VBA?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"bradasley" <(E-Mail Removed)> wrote in message
news:BF53EF12-09B1-4BAB-A0AF-(E-Mail Removed)...
> When opening a file by simply double clicking, the dates in the file
> remain
> in UK format.
>
> When opening the file as part of a macro, the dates where the the day is
> greater than 12 switches to US format.
>
> Does anyone know how I can stop the dates switching to US format?
>
> Thanks
>
> David



 
Reply With Quote
 
=?Utf-8?B?YnJhZGFzbGV5?=
Guest
Posts: n/a
 
      20th Feb 2007
It shows the date in us format in excel where the uk day is less than 12.

"Bob Phillips" wrote:

> When you say switches, do you mean in shows in US format in Excel, or you
> see US dates in VBA?
>
> --
> ---
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
>
>
> "bradasley" <(E-Mail Removed)> wrote in message
> news:BF53EF12-09B1-4BAB-A0AF-(E-Mail Removed)...
> > When opening a file by simply double clicking, the dates in the file
> > remain
> > in UK format.
> >
> > When opening the file as part of a macro, the dates where the the day is
> > greater than 12 switches to US format.
> >
> > Does anyone know how I can stop the dates switching to US format?
> >
> > Thanks
> >
> > David

>
>
>

 
Reply With Quote
 
Rob Edwards
Guest
Posts: n/a
 
      20th Feb 2007
Hi,
I presume that you are using the OpenText method to import the
info, which has a series of two-element arrays.

If yes, then the second element is a data type that interprets the
info. Use '4' to ensure the data is set in the DMY format.

Rob Edwards

Always look on the bright side of life!

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
=?Utf-8?B?YnJhZGFzbGV5?=
Guest
Posts: n/a
 
      20th Feb 2007
Hi,

Thanks for the advice, but can you explain what you mean by '4'?

"Rob Edwards" wrote:

> Hi,
> I presume that you are using the OpenText method to import the
> info, which has a series of two-element arrays.
>
> If yes, then the second element is a data type that interprets the
> info. Use '4' to ensure the data is set in the DMY format.
>
> Rob Edwards
>
> Always look on the bright side of life!
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
Reply With Quote
 
Rob Edwards
Guest
Posts: n/a
 
      21st Feb 2007
Hi,
The 4 is the data type that imports dates in the DMY format. For
instance...

Workbooks.OpenText Filename:="GRAHAM", Origin:=xlWindows _
, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0,
4), Array( _
23, 9), Array(26, 1)

The arrays above are in the form Array(n, m). The n = start position,
the m = data type.

The full list for the data types (m) is...

1 General Data
2 Text
3 MDY
4 DMY
5 YMD
6 MYD
7 DYM
8 YDM
9 Skipped

Therefore, from the first array above:

Array(0, 4) Start position 0 & import as DMY
Array(23, 9) Start position 23 & skip
Array(26, 1) Start position 26 & import as general data

Rob Edwards

Always look on the bright side of life!

*** Sent via Developersdex http://www.developersdex.com ***
 
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 format on opening a csv file in Excel 2007 =?Utf-8?B?R2xlYW0=?= Microsoft Excel Programming 1 4th Nov 2007 08:25 PM
Opening a csv file with US date format on a Australian PC =?Utf-8?B?VHJveSBMZWE=?= Microsoft Excel Misc 2 16th Mar 2005 10:05 PM
Why does date format change when opening outlook =?Utf-8?B?V2FsdGVyIFBlZXJsZXNz?= Microsoft Outlook Discussion 0 4th Dec 2004 12:11 PM
switched date format opening dbf file =?Utf-8?B?YWRhbUB0d3Yub3Jn?= Microsoft Excel Programming 1 16th Jul 2004 01:13 PM
Date format when opening a .CSV file programmatically jason Microsoft Excel Programming 3 10th Nov 2003 09:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:20 AM.