将 yyyymmdd 数字或字符串转换为 MS Access 中的真实日期值

Convert yyyymmdd number or string to true Date value in MS Access

我有一个查询,该查询的日期字段采用这种格式 (yyyymmdd),只是数字。我正在通过使用以下公式创建计算字段来重新格式化该字段:

[DateField] = Date(Left( [DateField] ,4),Mid( [DateField] ,5,2),Right( [DateField] ,2))

我不断收到一条消息,说我的公式包含错误数量的参数!! 此公式在 Excel 中始终有效。

请指教

干杯

在 Access 中,您需要使用 DateSerial() 函数:

DateSerial(Left([DateField], 4), Mid([DateField], 5, 2), Right([DateField], 2))

我建议使用 CDate 函数并以适当的格式输入日期

NewDate: CDate(Format([TextField], "0000-00-00"))