Dim mDocDtT As Date
Dim mDtPeriod as Integer = 4
mDocDtT = DateAdd(DateInterval.Month, mDtPeriod, mDocDtT)
mDocDtT = Format(mDocDtT, "yyyy-MM-dd")

But the codes are not working the date is still in #01/27/2011# format
I want it in yyyy-MM-dd format

Please help!!!

Recommended Answers

All 2 Replies

Member Avatar for Unhnd_Exception

Format returns a string.

To have a string in the format you want: Assign it to a string.

Dim mDocDtT As Date
    Dim mDtPeriod As Integer = 4
    mDocDtT = DateAdd(DateInterval.Month, mDtPeriod, mDocDtT)
    Dim dateString As String = Format(mDocDtT, "yyyy-MM-dd")
    MsgBox(dateString)

If this solves your problem mark it as solved. If not, say why it didn't solve your problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.