PC Review


Reply
Thread Tools Rate Thread

DateSerial vs Date??

 
 
Otto Moehrbach
Guest
Posts: n/a
 
      30th Nov 2009
Excel 2007 Win 7 64-bit
The range rColJ is a string of cells containing dates, the largest of which
is 6 Dec 09. That string of dates was not changed in the following
troubleshooting procedure.
I want to know if the maximum date in rColJ >= 1 Dec 09. My code is:
If Application.Max(rColJ)>DateSerial (2009, 12, 1) Then....
The argument is False, even though 6 Dec 09 is in that range.
I changed that line of code and substituted the numerical value of 6 Dec 09
(38686) for the DateSerial expression:
If Application.Max(rColJ)>38686 Then....
That argument is True.
What mistake did I make in using the DateSerial VBA function?
Thanks for your time. Otto

 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      1st Dec 2009

>If Application.Max(rColJ)>DateSerial (2009, 12, 1) Then....


If the date 1-December-2009 is the maximum date in rColj, the
condtional will be false because it equals DateSerial(2009,12,1) and
your test if for "greater than", not "greater than or equal to".
Change the ">" to ">=" if you want to include equality.

>If Application.Max(rColJ)>38686 Then....


The value 38686 is equivalent to 30-Nov-2005, which is certainly less
than 1-Dec-2009.

Think carefully about the logic you need and then write code
accordingly.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]




On Mon, 30 Nov 2009 16:32:35 -0500, "Otto Moehrbach"
<(E-Mail Removed)> wrote:

>Excel 2007 Win 7 64-bit
>The range rColJ is a string of cells containing dates, the largest of which
>is 6 Dec 09. That string of dates was not changed in the following
>troubleshooting procedure.
>I want to know if the maximum date in rColJ >= 1 Dec 09. My code is:
>If Application.Max(rColJ)>DateSerial (2009, 12, 1) Then....
>The argument is False, even though 6 Dec 09 is in that range.
>I changed that line of code and substituted the numerical value of 6 Dec 09
>(38686) for the DateSerial expression:
>If Application.Max(rColJ)>38686 Then....
>That argument is True.
>What mistake did I make in using the DateSerial VBA function?
>Thanks for your time. Otto

 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      1st Dec 2009
Chip
I did test for >= in my code, and the maximum date in rColJ was 6 Dec
09, not 1 Dec 09 (see my post). I did have the number, 38686, wrong. It
should have been 40148. Thanks for your time. Otto

"Chip Pearson" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
>
>>If Application.Max(rColJ)>DateSerial (2009, 12, 1) Then....

>
> If the date 1-December-2009 is the maximum date in rColj, the
> condtional will be false because it equals DateSerial(2009,12,1) and
> your test if for "greater than", not "greater than or equal to".
> Change the ">" to ">=" if you want to include equality.
>
>>If Application.Max(rColJ)>38686 Then....

>
> The value 38686 is equivalent to 30-Nov-2005, which is certainly less
> than 1-Dec-2009.
>
> Think carefully about the logic you need and then write code
> accordingly.
>
> Cordially,
> Chip Pearson
> Microsoft MVP 1998 - 2010
> Pearson Software Consulting, LLC
> www.cpearson.com
> [email on web site]
>
>
>
>
> On Mon, 30 Nov 2009 16:32:35 -0500, "Otto Moehrbach"
> <(E-Mail Removed)> wrote:
>
>>Excel 2007 Win 7 64-bit
>>The range rColJ is a string of cells containing dates, the largest of
>>which
>>is 6 Dec 09. That string of dates was not changed in the following
>>troubleshooting procedure.
>>I want to know if the maximum date in rColJ >= 1 Dec 09. My code is:
>>If Application.Max(rColJ)>DateSerial (2009, 12, 1) Then....
>>The argument is False, even though 6 Dec 09 is in that range.
>>I changed that line of code and substituted the numerical value of 6 Dec
>>09
>>(38686) for the DateSerial expression:
>>If Application.Max(rColJ)>38686 Then....
>>That argument is True.
>>What mistake did I make in using the DateSerial VBA function?
>>Thanks for your time. Otto


 
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
DateSerial-Calculating a date 35 days from today RLN60 Microsoft Access VBA Modules 5 31st Aug 2009 08:28 PM
Recreating the DateSerial()/Date() function Conan Kelly Microsoft Access 4 1st Mar 2008 03:44 PM
Recreating the DateSerial()/Date() function Conan Kelly Microsoft Excel Programming 1 1st Mar 2008 04:43 AM
Recreating the DateSerial()/Date() function Conan Kelly Microsoft Excel Worksheet Functions 1 1st Mar 2008 04:43 AM
is there date function like DateSerial? =?Utf-8?B?R2lz?= Microsoft Dot NET Framework 1 12th Nov 2004 02:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:55 AM.