如何将文本字段转换为Access 2010中的日期/时间字段? [英] How to convert a text field to a date/time field in Access 2010?
问题描述
我正在将Excel文件导入Access 2010,日期字段(CALLDATE)以文本形式(YYYYMMDD)输入。我想使用更新查询来更新新字段dateofcall,但使用日期/时间格式。我尝试使用:
I am importing an excel file into Access 2010 and the date field(CALLDATE) comes in as text(YYYYMMDD). I would like to use an update query to update a new field "dateofcall" but using a date/time format. I tried to use:
UPDATE tbl_Import SET tbl_Import.dateofcall = CDate([tbl_Import].[CALLDATE]);
我认为它会变得如此简单,但它会显示空白并带有日期格式。我也尝试使用DateSerriel()但仍然遇到错误。有什么建议?
I thought it was going to be that simple but it shows up blank with a date format. I also tried to use DateSerriel() but still was getting errors. Any suggestions?
推荐答案
您可以使用左,右和中间字符串函数从字符串的各个部分构造日期。
You can use left, right and mid string functions to construct a date from the various parts of the string.
例如:
DateSerial(Left(MyTextDate,4),Mid(MyTextDate,5,2),Right(MytextDate,2))
你可以使用上面的更新查询,以更新日期类型coulmn 9field)到文本列中的日期。
You can use the above in an Update query to update a date type coulmn 9field) to a the date from the text column.
这篇关于如何将文本字段转换为Access 2010中的日期/时间字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!