DTPicker date stored as variable

I want to store the formatted date as a string variable to use in other places.  I have tried the following code:

Dim Letter_Date As String
Letter_Date = Form1.DTPicker1.Value

But the variable Letter_Date comes back as 05/05/00, but I want it to be May 5, 2000.

The control is displaying the date in the correct format, so my question is how do you store the displayed (formatted) date as a variable?

Thank you,


mhewesAsked:
Who is Participating?
 
AnswerTheManConnect With a Mentor Commented:
Dim X As Date
    X = DTPicker1.Value
    MsgBox FormatDateTime(X, vbLongDate)
0
 
GivenRandyCommented:
Doubleclick on the DateTimePicker control.

Set the type to:

3 - dtpCustom

In the CustomFormat field, set to:

MMM d, yyyy

Or, if you want two digit days:

MMM dd, yyyy
0
 
GivenRandyCommented:
I mean, right-click then Properties.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
mhewesAuthor Commented:
This has already been done.  I stated in the question that DTPicker is displaying the correct format.  What I want to do is to store the formatted date to a string variable so that I can insert the date into other text.

Thanks,

0
 
AnswerTheManCommented:
Dim X As String
X = FormatDateTime(DTPicker1.Value, vbLongDate)
MsgBox X
0
 
mhewesAuthor Commented:
Thanks AnswerMan, that was too easy for you!

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.