Home > DeveloperSection > Forums > Getting month and year date format in vbscript
Pravesh Singh

Total Post:411

Points:2881
Posted on    June-20-2013 1:40 AM

 VB Script VB Script 
Ratings:


 1 Reply(s)
 791  View(s)
Rate this:
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



Vijay Shukla

Total Post:100

Points:700
Posted on    June-20-2013 5:16 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick