Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
CDate or CVDate
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
CDate or CVDate
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
cdate problem | Excel Programming | |||
CDate Problem | Excel Programming | |||
CDate and IsDate | Excel Programming | |||
CDATE issues | Excel Programming | |||
What is the differance between cdate and ... | Excel Programming |