From string to long date

  • Thread starter Thread starter abou_ddan
  • Start date Start date
A

abou_ddan

I am having some problems with converting a string type data to long date
type. Simply I am trying to compare two dates, the first being captured from
a text document and the other from the system. For ex. I want : "Monday, July
10, 2006" (as String) to be compared with the system date. ( CDate() do not
work )
Any Help on this?
thx.
 
If all records consistently have the weekday name followed by a comma as the
start of the date, use Instr() to find the first comma, Mid() to parse the
rest of the string, and CDate() to convert it to a date.

This example assumes the field is named "d":
CDate(Mid([d] ,Instr([d], ",")+1))
 
Thx for reply,

I already tried somthing like that and even I just tried this one, an "Type
mismatch" error occurs (error # 13).
That's what I can't understand...
What can we do about this?

Thx have a nice day!
 
Filter out the nulls.

Add the [d] field to the grid.
In the Criteria row under this field, enter:
Is Not Null
 
An alternative would be to convert the date() to a string using the Format
function and compare two strings.

SomeStringDateField = Format(Date(),"Long Date")


Allen Browne said:
Filter out the nulls.

Add the [d] field to the grid.
In the Criteria row under this field, enter:
Is Not Null

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

abou_ddan via AccessMonster.com said:
Thx for reply,

I already tried somthing like that and even I just tried this one, an
"Type
mismatch" error occurs (error # 13).
That's what I can't understand...
What can we do about this?
 
Thx for the reply
This Format() function converts the system Date to String witches I do not
need, thanks anyway. Simply I want the deference (in days) between two dates,
and in order to use the DateDiff() function the two entries should be a Date
data type. So I have to convert the first entry from String to Date...
 
OK. I read your original post where you said you wanted to "compare" two
dates.

Quote:
I am trying to compare two dates, the first being captured from
a text document and the other from the system. For ex. I want : "Monday,
July
10, 2006" (as String) to be compared with the system date
End Quote.

In examining my reply, I realized that using the strings would only work if
you were testing for equality or inequality of the two values. So
obviously, Allen Browne's solution is much better for you (and as a general
solution).
 
Back
Top