Thread: CDate or CVDate
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default CDate or CVDate

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
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