在Access中将字符串转换为日期 [英] Convert a string to a date in Access

查看:1225
本文介绍了在Access中将字符串转换为日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Access 2003中的表之间迁移数据.在旧表中,日期以YYYYMMDD格式存储为文本字段.

I'm migrating data between tables in Access 2003. In the old table, the date was stored as a text field in the format YYYYMMDD.

我想将该字段存储为新表中的日期时间.我尝试在SQL语句中使用CDate(),但结果中显示为#Error.

I want to store the field as a datetime in the new table. I've tried using CDate() in my SQL statement, but it just displays as #Error in the results.

我在做什么错了?

推荐答案

例如cdate(format("20091231", "####/##/##"))

因此,您的情况将是

SELECT cdate(format(mystringFieldThatIsInYYYYMMDDFormat, "####/##/##"))   
FROM myData

这篇关于在Access中将字符串转换为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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