Format datetime in string フォローする

John Smithy

I have a barcode that I push data to that contains text and date however I would like to format the date to either just the month and the last two digits of the year or just the last two digits of the year. I tried this code but I keep getting this error Sub of function not defined


dim p
p= "2ID589517531 5/31/2019 1:45:00 PM"
If Format.NamedSubStrings("csn").Value like p then
value = value=right(Format.NamedSubStrings("csn").Value,13,YY)
end if

1 コメント

Pete Thane
コメントアクション Permalink

The Like command is not present in VB script.

If the data string is always the same length you could just extract the date elements you want from the string something like this (there are probably better ways to code it , but this works)

Value = Format.NamedSubStrings("csn").Value

Value = Right(Value,21)

Value1 = Left(Value,10)

Value2 = Left(Value1,2)

Value3 = Right(Value1,2)

Value = Value2 & "/" & Value3


(You may have to make this and event controlled script to be processed after the barcode data is entered, such as OnIndenticalCopies for example)