VB6:将字符串[28Aug2013]转换为日期[2013年8月28日] [英] VB6 : Convert String[28Aug2013] to Date[28-Aug-2013]
问题描述
如何将字符串[28Aug2013]转换为日期类型[2013年8月28日]
我尝试使用CDate转换函数,但失败了,因为它只能转换格式为[dd / mmm]的字符串/ yyyy]或[dd-mmm-yyyy]。即只有日期格式化的字符串。
现在问题是我无法将字符串格式从28Aug2013更改为2013年8月28日或2013年8月28日。
所以请为这个问题提出一个解决方案。最后,我希望将字符串[28Aug2013]转换为日期类型
谢谢。
Dinesh
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
推荐答案
您可以轻松地将输入字符串转换为CDate
函数接受一个,只需使用Mid
函数(可选择你也可以使用左
和右
)和字符串连接运算符。
You may easily transform your input string into aCDate
function accepted one, just using theMid
function (optionally you may use alsoLeft
andRight
) and the string concatenation operator.
使用
Use
Format
(YourDate, d-mmm-yyyy)
(YourDate, "d-mmm-yyyy")
2013年8月2日
或者>
for 2-Aug-2013
Or
Format
这篇关于VB6:将字符串[28Aug2013]转换为日期[2013年8月28日]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!