Advertise with us

Getting month and year date format in vbscript

Hi,

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

Last updated:6/20/2013 5:16:19 AM

1 Answers

Vijay Shukla
Vijay Shukla

Hi Expert!


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

Answer