Local Date Format Change

R

RobV

I have a VBA macro that works with task dates. Some schedules use the
US-English Regional setting as the default format, and others use
Canadian-English format. The two formats have a different order and
presentation for month and day. This is causing the macro to misbehave. How
do I force the dates into a single format prior to processing?
 
J

John

RobV said:
I have a VBA macro that works with task dates. Some schedules use the
US-English Regional setting as the default format, and others use
Canadian-English format. The two formats have a different order and
presentation for month and day. This is causing the macro to misbehave. How
do I force the dates into a single format prior to processing?

Robv,
It kind of depends on how you are using the date values in your code.
Most normal use of dates is independent of the date order. However in
certain circumstances, (and I've had to deal with them), it is important
to know the date order and sometimes even the date format (i.e. with or
without time, short year or long year, etc.). Here is what I suggest.
Use the following test at the beginning of your code:
If application.DateOrder <> pjMonthDayYear Then
[set a flag]
End If

Then, for lines of code that are sensitive to the date order, use string
manipulation to convert the date order. I find the Month, Day, and Year
functions along with the Mid function to be very useful for rearranging
dates.

Hope this helps.
John
Project MVP
 
R

RobV

John, that solved my problem. Thank you.

John said:
RobV said:
I have a VBA macro that works with task dates. Some schedules use the
US-English Regional setting as the default format, and others use
Canadian-English format. The two formats have a different order and
presentation for month and day. This is causing the macro to misbehave. How
do I force the dates into a single format prior to processing?

Robv,
It kind of depends on how you are using the date values in your code.
Most normal use of dates is independent of the date order. However in
certain circumstances, (and I've had to deal with them), it is important
to know the date order and sometimes even the date format (i.e. with or
without time, short year or long year, etc.). Here is what I suggest.
Use the following test at the beginning of your code:
If application.DateOrder <> pjMonthDayYear Then
[set a flag]
End If

Then, for lines of code that are sensitive to the date order, use string
manipulation to convert the date order. I find the Month, Day, and Year
functions along with the Mid function to be very useful for rearranging
dates.

Hope this helps.
John
Project MVP
 
J

John

RobV said:
John, that solved my problem. Thank you.

RobV,
You're welcome and thanks for the feedback.
John
John said:
RobV said:
I have a VBA macro that works with task dates. Some schedules use the
US-English Regional setting as the default format, and others use
Canadian-English format. The two formats have a different order and
presentation for month and day. This is causing the macro to misbehave.
How
do I force the dates into a single format prior to processing?

Robv,
It kind of depends on how you are using the date values in your code.
Most normal use of dates is independent of the date order. However in
certain circumstances, (and I've had to deal with them), it is important
to know the date order and sometimes even the date format (i.e. with or
without time, short year or long year, etc.). Here is what I suggest.
Use the following test at the beginning of your code:
If application.DateOrder <> pjMonthDayYear Then
[set a flag]
End If

Then, for lines of code that are sensitive to the date order, use string
manipulation to convert the date order. I find the Month, Day, and Year
functions along with the Mid function to be very useful for rearranging
dates.

Hope this helps.
John
Project MVP
 
S

Scudder

Rob, John,

Now I'm intrigued...

I receive project plans from global divisions every week, each plan is
scanned for status update (including dates) via the MS Project object model.

The dates are always in a consistent (US) format, this is as they should be
since MS Office applications convert dates to use local formatting regardless
of where they originate.

How and where exactly are you encountering these multiple date formats ?

Lee.

John said:
RobV said:
John, that solved my problem. Thank you.

RobV,
You're welcome and thanks for the feedback.
John
John said:
I have a VBA macro that works with task dates. Some schedules use the
US-English Regional setting as the default format, and others use
Canadian-English format. The two formats have a different order and
presentation for month and day. This is causing the macro to misbehave.
How
do I force the dates into a single format prior to processing?

Robv,
It kind of depends on how you are using the date values in your code.
Most normal use of dates is independent of the date order. However in
certain circumstances, (and I've had to deal with them), it is important
to know the date order and sometimes even the date format (i.e. with or
without time, short year or long year, etc.). Here is what I suggest.
Use the following test at the beginning of your code:
If application.DateOrder <> pjMonthDayYear Then
[set a flag]
End If

Then, for lines of code that are sensitive to the date order, use string
manipulation to convert the date order. I find the Month, Day, and Year
functions along with the Mid function to be very useful for rearranging
dates.

Hope this helps.
John
Project MVP
 
J

John

Scudder said:
Rob, John,

Now I'm intrigued...

I receive project plans from global divisions every week, each plan is
scanned for status update (including dates) via the MS Project object model.

The dates are always in a consistent (US) format, this is as they should be
since MS Office applications convert dates to use local formatting regardless
of where they originate.

How and where exactly are you encountering these multiple date formats ?
Scudder,
Depending on which fields contain the dates, they will NOT automatically
take on the system setting for date format. For example, if dates are
contained in spare fields, they are treated as text.

The other possibility is that Rob's macro is being used by his Canadian
coworkers on THEIR PCs, which are most likely set for Canadian date
format.

John
Project MVP
Lee.

John said:
RobV said:
John, that solved my problem. Thank you.

RobV,
You're welcome and thanks for the feedback.
John
:

I have a VBA macro that works with task dates. Some schedules use
the
US-English Regional setting as the default format, and others use
Canadian-English format. The two formats have a different order and
presentation for month and day. This is causing the macro to
misbehave.
How
do I force the dates into a single format prior to processing?

Robv,
It kind of depends on how you are using the date values in your code.
Most normal use of dates is independent of the date order. However in
certain circumstances, (and I've had to deal with them), it is
important
to know the date order and sometimes even the date format (i.e. with or
without time, short year or long year, etc.). Here is what I suggest.
Use the following test at the beginning of your code:
If application.DateOrder <> pjMonthDayYear Then
[set a flag]
End If

Then, for lines of code that are sensitive to the date order, use
string
manipulation to convert the date order. I find the Month, Day, and Year
functions along with the Mid function to be very useful for rearranging
dates.

Hope this helps.
John
Project MVP
 
S

Scudder

Ah, that clarifies it. Thanks John.

I thought I was missing something there.

John said:
Scudder said:
Rob, John,

Now I'm intrigued...

I receive project plans from global divisions every week, each plan is
scanned for status update (including dates) via the MS Project object model.

The dates are always in a consistent (US) format, this is as they should be
since MS Office applications convert dates to use local formatting regardless
of where they originate.

How and where exactly are you encountering these multiple date formats ?
Scudder,
Depending on which fields contain the dates, they will NOT automatically
take on the system setting for date format. For example, if dates are
contained in spare fields, they are treated as text.

The other possibility is that Rob's macro is being used by his Canadian
coworkers on THEIR PCs, which are most likely set for Canadian date
format.

John
Project MVP
Lee.

John said:
John, that solved my problem. Thank you.

RobV,
You're welcome and thanks for the feedback.
John

:

I have a VBA macro that works with task dates. Some schedules use
the
US-English Regional setting as the default format, and others use
Canadian-English format. The two formats have a different order and
presentation for month and day. This is causing the macro to
misbehave.
How
do I force the dates into a single format prior to processing?

Robv,
It kind of depends on how you are using the date values in your code.
Most normal use of dates is independent of the date order. However in
certain circumstances, (and I've had to deal with them), it is
important
to know the date order and sometimes even the date format (i.e. with or
without time, short year or long year, etc.). Here is what I suggest.
Use the following test at the beginning of your code:
If application.DateOrder <> pjMonthDayYear Then
[set a flag]
End If

Then, for lines of code that are sensitive to the date order, use
string
manipulation to convert the date order. I find the Month, Day, and Year
functions along with the Mid function to be very useful for rearranging
dates.

Hope this helps.
John
Project MVP
 
J

John

Scudder said:
Ah, that clarifies it. Thanks John.

I thought I was missing something there.
Scudder,
You are welcome and thanks for the feedback.
John
John said:
Scudder said:
Rob, John,

Now I'm intrigued...

I receive project plans from global divisions every week, each plan is
scanned for status update (including dates) via the MS Project object
model.

The dates are always in a consistent (US) format, this is as they should
be
since MS Office applications convert dates to use local formatting
regardless
of where they originate.

How and where exactly are you encountering these multiple date formats ?
Scudder,
Depending on which fields contain the dates, they will NOT automatically
take on the system setting for date format. For example, if dates are
contained in spare fields, they are treated as text.

The other possibility is that Rob's macro is being used by his Canadian
coworkers on THEIR PCs, which are most likely set for Canadian date
format.

John
Project MVP
Lee.

:

John, that solved my problem. Thank you.

RobV,
You're welcome and thanks for the feedback.
John

:

I have a VBA macro that works with task dates. Some schedules
use
the
US-English Regional setting as the default format, and others use
Canadian-English format. The two formats have a different order
and
presentation for month and day. This is causing the macro to
misbehave.
How
do I force the dates into a single format prior to processing?

Robv,
It kind of depends on how you are using the date values in your
code.
Most normal use of dates is independent of the date order. However
in
certain circumstances, (and I've had to deal with them), it is
important
to know the date order and sometimes even the date format (i.e.
with or
without time, short year or long year, etc.). Here is what I
suggest.
Use the following test at the beginning of your code:
If application.DateOrder <> pjMonthDayYear Then
[set a flag]
End If

Then, for lines of code that are sensitive to the date order, use
string
manipulation to convert the date order. I find the Month, Day, and
Year
functions along with the Mid function to be very useful for
rearranging
dates.

Hope this helps.
John
Project MVP
 
R

RobV

John's last scenario is the correct one. Canadian PCs have the regional
settings defaulted to English - Canada.

John said:
Scudder said:
Ah, that clarifies it. Thanks John.

I thought I was missing something there.
Scudder,
You are welcome and thanks for the feedback.
John
John said:
Rob, John,

Now I'm intrigued...

I receive project plans from global divisions every week, each plan is
scanned for status update (including dates) via the MS Project object
model.

The dates are always in a consistent (US) format, this is as they should
be
since MS Office applications convert dates to use local formatting
regardless
of where they originate.

How and where exactly are you encountering these multiple date formats ?
Scudder,
Depending on which fields contain the dates, they will NOT automatically
take on the system setting for date format. For example, if dates are
contained in spare fields, they are treated as text.

The other possibility is that Rob's macro is being used by his Canadian
coworkers on THEIR PCs, which are most likely set for Canadian date
format.

John
Project MVP

Lee.

:

John, that solved my problem. Thank you.

RobV,
You're welcome and thanks for the feedback.
John

:

I have a VBA macro that works with task dates. Some schedules
use
the
US-English Regional setting as the default format, and others use
Canadian-English format. The two formats have a different order
and
presentation for month and day. This is causing the macro to
misbehave.
How
do I force the dates into a single format prior to processing?

Robv,
It kind of depends on how you are using the date values in your
code.
Most normal use of dates is independent of the date order. However
in
certain circumstances, (and I've had to deal with them), it is
important
to know the date order and sometimes even the date format (i.e.
with or
without time, short year or long year, etc.). Here is what I
suggest.
Use the following test at the beginning of your code:
If application.DateOrder <> pjMonthDayYear Then
[set a flag]
End If

Then, for lines of code that are sensitive to the date order, use
string
manipulation to convert the date order. I find the Month, Day, and
Year
functions along with the Mid function to be very useful for
rearranging
dates.

Hope this helps.
John
Project MVP
 
J

John

RobV said:
John's last scenario is the correct one. Canadian PCs have the regional
settings defaulted to English - Canada.

RobV,
I thought that was the case based on your first post, but I thought it
relevant to also list other reasons why date formats might cause
problems.

John
John said:
Scudder said:
Ah, that clarifies it. Thanks John.

I thought I was missing something there.
Scudder,
You are welcome and thanks for the feedback.
John
:

Rob, John,

Now I'm intrigued...

I receive project plans from global divisions every week, each plan
is
scanned for status update (including dates) via the MS Project object
model.

The dates are always in a consistent (US) format, this is as they
should
be
since MS Office applications convert dates to use local formatting
regardless
of where they originate.

How and where exactly are you encountering these multiple date
formats ?
Scudder,
Depending on which fields contain the dates, they will NOT
automatically
take on the system setting for date format. For example, if dates are
contained in spare fields, they are treated as text.

The other possibility is that Rob's macro is being used by his Canadian
coworkers on THEIR PCs, which are most likely set for Canadian date
format.

John
Project MVP

Lee.

:

John, that solved my problem. Thank you.

RobV,
You're welcome and thanks for the feedback.
John

:


I have a VBA macro that works with task dates. Some
schedules
use
the
US-English Regional setting as the default format, and others
use
Canadian-English format. The two formats have a different
order
and
presentation for month and day. This is causing the macro to
misbehave.
How
do I force the dates into a single format prior to
processing?

Robv,
It kind of depends on how you are using the date values in your
code.
Most normal use of dates is independent of the date order.
However
in
certain circumstances, (and I've had to deal with them), it is
important
to know the date order and sometimes even the date format (i.e.
with or
without time, short year or long year, etc.). Here is what I
suggest.
Use the following test at the beginning of your code:
If application.DateOrder <> pjMonthDayYear Then
[set a flag]
End If

Then, for lines of code that are sensitive to the date order,
use
string
manipulation to convert the date order. I find the Month, Day,
and
Year
functions along with the Mid function to be very useful for
rearranging
dates.

Hope this helps.
John
Project MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top