Outlook 中的日期格式问题,而 Excel-Outlook 自动化

发布于 2024-12-28 00:34:13 字数 153 浏览 2 评论 0原文

我已使用宏将电子邮件导出到 Excel。通过使用 Mid 函数,我在电子邮件中找到了日期,但它的格式不是日期。

例如 2012 年 1 月 12 日星期四上午 8:30 此日期是文本,而不是格式化日期。如何将其格式化为日期?

I have exported email mesages to excel by using a macro. By using Mid function I have found the date in the email, but it's not formated as a date.

For example Thursday, January 12, 2012 8:30 AM This date is text, not a formated date. How do I format that as a date?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ま柒月 2025-01-04 00:34:13

您需要先删除“星期四”。然后使用CDate。这应该有效

DateStr = "Thursday, January 12, 2012 8:30 AM"
DateStr = Mid(DateStr, InStr(1, DateStr, ", ") + 1)
DateVal = CDate(DateStr)

You'll need to take out "Thursday, " bit first. And then use CDate. This Should Work

DateStr = "Thursday, January 12, 2012 8:30 AM"
DateStr = Mid(DateStr, InStr(1, DateStr, ", ") + 1)
DateVal = CDate(DateStr)
叫嚣ゝ 2025-01-04 00:34:13

尝试:

Format(DateValue, "dddd, mmmm d, yyyy hh:mm AM/PM")

Try:

Format(DateValue, "dddd, mmmm d, yyyy hh:mm AM/PM")
清风不识月 2025-01-04 00:34:13

如果您需要公式解决方案:

假设单元格 A1 中包含以下内容:

Thursday, January 12, 2012 8:30 AM

以下公式将提取日期部分并对其进行格式化作为日期:

=DATEVALUE(MID(A1,FIND(",",A1)+1,LEN(A1)))

这将显示单元格中的40920。将单元格格式设置为日期,将其显示为 mm/dd/yyyy 日期(或者您想要的格式)。

If you wanted a formula solution:

Assume the following is in cell A1:

Thursday, January 12, 2012 8:30 AM

The following formula will extract the date portion and format it as a date:

=DATEVALUE(MID(A1,FIND(",",A1)+1,LEN(A1)))

This will show 40920 in the cell. Format the cell as Date to display it as a mm/dd/yyyy date (or however you want to format it).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文