user505210
user505210

Reputation: 1402

Getting month and year date format in vbscript

Can someone please tell me how can we get data in the month and date format.In the below code it shows me the year with the same date one year ago in the format 6/18/2012 ..but I just need the month/year.

LastMonth = DateAdd("m",-12,Date)

Thanks

Upvotes: 0

Views: 2230

Answers (1)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38745

Use the specialized functions Month(), Year(), ... to get at the private parts of a (variable of type) Date:

>> dt = DateAdd("m",-12,Date)
>> WScript.Echo TypeName(dt), CStr(dt), Month(dt) & "/" & Year(dt)
>>
Date 6/18/2012 6/2012

Upvotes: 2

Related Questions