How to convert mm/dd/yyyy date format to yyyy-mm-dd

  • Thread starter Thread starter masani paresh
  • Start date Start date
M

masani paresh

Hi Friends,

Could anyone please tell me how I can convert mm/dd/yyyy date format to
yyyy-mm-dd in VBScript.

Thanks,
Megha
 
Use the Format() function. If your date is myDate then Format(myDate,
"yyyy-mm-dd")
 
Hey Ken,

I am using this function with my outlook project. But it gives the error
message saying "Variable is undefined Format" in following line.

MsgBox DateValue(Item.Start) & " " & Format(Item.Start,"yyyy-mm-dd")

Thanks,
Paresh
 
Hi Ken, I got the solution. We need to add following function in the code.
Thanks for you initial reply.

Function Format(vExpression, sFormat)
set fmt = CreateObject("MSSTDFMT.StdDataFormat")
fmt.Format = sFormat

set rs = CreateObject("ADODB.Recordset")
rs.Fields.Append "fldExpression", 12 ' adVariant

rs.Open
rs.AddNew

set rs("fldExpression").DataFormat = fmt
rs("fldExpression").Value = vExpression

Format = rs("fldExpression").Value

rs.close: Set rs = Nothing: Set fmt = Nothing
End Function


Thanks,
Paresh
 
Back
Top