Use Split () to get parts of your input string. Load the correct parts into DateSerial () / CDate () to get a Date that should display / print as / d / m / y if it suits your language requirements / regional settings. If you do not need a date, create the desired String through Join (). How in:
Option Explicit Function mkDicMonth() Dim dicT : Set dicT = CreateObject("Scripting.Dictionary") Dim i For i = 1 To 12 dicT(MonthName(i, True)) = i Next Set mkDicMonth = dicT End Function Dim sInp : sInp = "Wed, 10 Jan 2018 17:23:34 UTC" Dim dicM : Set dicM = mkDicMonth() Dim aParts : aParts = Split(sInp) Dim sOtp : sOtp = Join(Array(aParts(1), dicM(aParts(2)), aParts(3)), "/") WScript.Echo TypeName(sOtp), sOtp Dim dtOtp ' DateSerial dtOtp = DateSerial(CInt(aParts(3)), CInt(dicM(aParts(2))), CInt(aParts(1))) WScript.Echo 1, TypeName(dtOtp), dtOtp, "(german locale, dmy)" ' CDate (risky, order, locale dependent) dtOtp = CDate(sOtp) WScript.Echo 2, TypeName(dtOtp), dtOtp, "(german locale, dmy)" ' CDate (risky, monthname, locale dependent) dtOtp = CDate(Join(Array(aParts(1), aParts(2), aParts(3)))) WScript.Echo 3, TypeName(dtOtp), dtOtp, "(german locale, dmy)"
exit:
cscript 48193001.vbs String 10/1/2018 1 Date 10.01.2018 (german locale, dmy) 2 Date 10.01.2018 (german locale, dmy) 3 Date 10.01.2018 (german locale, dmy)
Ekkehard.Horner
source share