VB6:将字符串[28Aug2013]转换为日期[2013年8月28日] [英] VB6 : Convert String[28Aug2013] to Date[28-Aug-2013]

查看:213
本文介绍了VB6:将字符串[28Aug2013]转换为日期[2013年8月28日]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将字符串[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 a CDate function accepted one, just using the Mid function (optionally you may use also Left and Right) 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆