Tuesday, December 15, 2015

Parse Date in VB6

VB6 is not smart to understand some usual date formats that we use daily.
So for example, if you were to put yyymmdd in date type, VB6 will give Type mismatch error.


You would need to parse it to store in date type field as below:


Dim strDate as string
Dim dBusinessDate as date


strDate = "20151211"
dBusinessDate = Mid(strDate, 5, 2) & "/" & Right(strDate, 2) & "/" & Left(strDate, 4)

For more info: See Dates on MS page




HTH

No comments: