p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

pro_vb thread: how to enclose a Date type with Pound signs (#) to be used in cDate()

Message #1 by "Michael Z" <mikezat@y...> on Thu, 26 Apr 2001 21:11:51
(Following is a copy of the answer I sent you via ASKME.COM)

Hehehe... I got this question in two places. I am also subscribed to the
Wrox P2P lists that you sent this question to. For your convenience, I will
send this answer to both places.

If the date is in a variable, as I understand it, you do not need the ##'s.
You should be able to set myDate equal to any valid date and then:


Otherwise, try this:

cDate("#" & myDate & "#")

If neither of those works, let me know and I will play around with it myself
to see what I can come up with.



-----Original Message-----
From: Michael Z [mailto:mikezat@y...]
Sent: Thursday, April 26, 2001 3:12 PM
To: professional vb
Subject: [pro_vb] how to enclose a Date type with Pound signs (#) to be
used in cDate()

In order to make my date independent of system locale
Microsoft suggests that I pass a date into cDate 
enclosed with the pound signs 
For example, cDate(#02/05/99#)

if I have a var named myDate:

dim myDate as Date
dim myDate as String

myDate = "02/05/99" 

How do I enclose myDate with the pound signs
so I can do 
myDate = cDate(myDate)

When I do this:

myDate= "#" & myDate& "#"
Debug.Print myDate
Debug.Print CDate(myDate)

I am getting type mismatch error.
What am I doing wrong?
How would you solve this problem?

Any help is greatly appreciated

  Return to Index