Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Date Problem in VBA

Hi All
I'm importing data from an Access query in to an Excel pivot table and as I
many of these imports to do I set the following constants in a standatd
module.
Private Const YearStart As Date = #1/4/2007#
Private Const YearEnd As Date = #31/3/2008#

The Dates I need are 1st April 2007 to 31st March 2008 however the date
#1/4/2007# is changed by Excel to #4/1/2007# so that the pivottable show for
the 1st january 2007. I've chacked the Windows XP Regional setting for the
date and are dd/mm/yyyy which is ok. Is there another setting somewhere? Any
suggesstions as to why the date #1/4/2007# is being changed?

TIA
johnb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Date Problem in VBA

VBA is pretty USA centric.

I'd try the USA settings: #4/1/2007# (for April 1, 2007)

Personally, I'd try to remove any ambiguity:

Private YearStart as Date
....

Later
yearstart = dateserial(2007,4,1)

===
I have no idea how Access queries work, though.

johnb wrote:

Hi All
I'm importing data from an Access query in to an Excel pivot table and as I
many of these imports to do I set the following constants in a standatd
module.
Private Const YearStart As Date = #1/4/2007#
Private Const YearEnd As Date = #31/3/2008#

The Dates I need are 1st April 2007 to 31st March 2008 however the date
#1/4/2007# is changed by Excel to #4/1/2007# so that the pivottable show for
the 1st january 2007. I've chacked the Windows XP Regional setting for the
date and are dd/mm/yyyy which is ok. Is there another setting somewhere? Any
suggesstions as to why the date #1/4/2007# is being changed?

TIA
johnb


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Date Problem in VBA

Hi Dave

Yeah. good point to define it later I shall try it!
regards
johnb

"Dave Peterson" wrote:

VBA is pretty USA centric.

I'd try the USA settings: #4/1/2007# (for April 1, 2007)

Personally, I'd try to remove any ambiguity:

Private YearStart as Date
....

Later
yearstart = dateserial(2007,4,1)

===
I have no idea how Access queries work, though.

johnb wrote:

Hi All
I'm importing data from an Access query in to an Excel pivot table and as I
many of these imports to do I set the following constants in a standatd
module.
Private Const YearStart As Date = #1/4/2007#
Private Const YearEnd As Date = #31/3/2008#

The Dates I need are 1st April 2007 to 31st March 2008 however the date
#1/4/2007# is changed by Excel to #4/1/2007# so that the pivottable show for
the 1st january 2007. I've chacked the Windows XP Regional setting for the
date and are dd/mm/yyyy which is ok. Is there another setting somewhere? Any
suggesstions as to why the date #1/4/2007# is being changed?

TIA
johnb


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Date Problem in VBA

I'm using a UK date format eg dd/mm/yyyy and I use a Yearstart as a Const coz
it's referred to many time in the module. So I need to force a UK date format
and my brains on strike. Ant ideas?
regards

johnb

"johnb" wrote:

Hi Dave

Yeah. good point to define it later I shall try it!
regards
johnb

"Dave Peterson" wrote:

VBA is pretty USA centric.

I'd try the USA settings: #4/1/2007# (for April 1, 2007)

Personally, I'd try to remove any ambiguity:

Private YearStart as Date
....

Later
yearstart = dateserial(2007,4,1)

===
I have no idea how Access queries work, though.

johnb wrote:

Hi All
I'm importing data from an Access query in to an Excel pivot table and as I
many of these imports to do I set the following constants in a standatd
module.
Private Const YearStart As Date = #1/4/2007#
Private Const YearEnd As Date = #31/3/2008#

The Dates I need are 1st April 2007 to 31st March 2008 however the date
#1/4/2007# is changed by Excel to #4/1/2007# so that the pivottable show for
the 1st january 2007. I've chacked the Windows XP Regional setting for the
date and are dd/mm/yyyy which is ok. Is there another setting somewhere? Any
suggesstions as to why the date #1/4/2007# is being changed?

TIA
johnb


--

Dave Peterson

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
Exel increment date problem wrt todays date. [email protected] Excel Worksheet Functions 1 November 11th 07 06:58 PM
Date Formula Problem - Leave date blank if Null Gayla Excel Worksheet Functions 5 April 24th 07 09:42 PM
Us date versus EU date problem Jan T. Excel Programming 7 October 2nd 06 07:06 PM
DAte problem again simoncottle[_2_] Excel Programming 7 April 4th 06 08:41 AM
Date problem using VBA Jean Mark New Users to Excel 3 July 28th 05 07:30 AM


All times are GMT +1. The time now is 10:20 PM.

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

About Us

"It's about Microsoft Excel"