Click here to Skip to main content
15,881,801 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to convert a string [28Aug2013] to Date type [28-Aug-2013]
I tried using CDate conversion func, but failed as it can only convert strings in format [dd/mmm/yyyy] OR [dd-mmm-yyyy] only. i.e only date formatted strings.

Now the problem here is i can't change the string format from 28Aug2013 to 28-Aug-2013 or 28/Aug/2013.

So please suggest a solution for this problem.In the end, i want the string [28Aug2013] to be converted to Date type

Thanks.
Dinesh
Posted
Comments
Menon Santosh 28-Aug-13 8:21am    
if cdate function is not working then you will have to split this string programmaticly to make it in valid format

You may easily transform your input string into a CDate function accepted one, just using the Mid function (optionally you may use also Left and Right) and the string concatenation operator.
 
Share this answer
 
Use

VB
Format$(YourDate, "d-mmm-yyyy")
for 2-Aug-2013

Or
VB
Format$(YourDate, "dd-mmm-yyyy")
for 02-Aug-2013
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900