PC Review


Reply
Thread Tools Rate Thread

CDate or CVDate

 
 
David
Guest
Posts: n/a
 
      6th Aug 2009
Hi Group,

If MyValueDate < FirstDate Then Stop, problem is that MyDateValue is a
string and FirstDate is a Date.

I have tried CVDate(MyValueDate) and CDate(MyValueDate), but MyValueDate
remains a string.

Anyone help?
Thanks,
David
 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      6th Aug 2009
Use DateVaue to convert the string date to a real date, and then
compare that to your FirstDate date value. DateValue uses the Windows
regional settings to determine is the input string is a valid date and
what date it represents. E.g,

Dim FirstDate As Date
Dim MyDateValue As String
FirstDate = DateSerial(2009, 11, 5)
MyDateValue = "October 2, 2009"
If DateValue(MyDateValue) < FirstDate Then
Debug.Print "MyDateValue is earlier"
Else
Debug.Print "MyDateValue is later"
End If

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 5 Aug 2009 17:14:09 -0700, David
<(E-Mail Removed)> wrote:

>Hi Group,
>
>If MyValueDate < FirstDate Then Stop, problem is that MyDateValue is a
>string and FirstDate is a Date.
>
>I have tried CVDate(MyValueDate) and CDate(MyValueDate), but MyValueDate
>remains a string.
>
>Anyone help?
>Thanks,
>David

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      6th Aug 2009
How did you declare myValueDate--as a string, a date or a variant?

Dim myValueDate as Variant 'could be a date or string!
myvaluedate = "June 23, 1989"
myvaluedate = cdate(myvaluedate)
msgbox format(myvaluedate, "yyyy-mmmm-dd")



David wrote:
>
> Hi Group,
>
> If MyValueDate < FirstDate Then Stop, problem is that MyDateValue is a
> string and FirstDate is a Date.
>
> I have tried CVDate(MyValueDate) and CDate(MyValueDate), but MyValueDate
> remains a string.
>
> Anyone help?
> Thanks,
> David


--

Dave Peterson
 
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
Cdate does not help jodleren Microsoft Excel Programming 1 19th Mar 2010 11:49 AM
Use of CDate Nigel Microsoft Access External Data 2 12th Aug 2009 04:23 PM
cdate cj2 Microsoft VB .NET 6 25th Feb 2009 04:06 PM
Using CVDate and Between And operator in SQL select statement =?Utf-8?B?RXJpYw==?= Microsoft Access VBA Modules 1 13th Jun 2006 03:43 PM
Re: cdate Teemu Keiski Microsoft ASP .NET 0 3rd Jul 2004 04:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:13 PM.