日期时间和转换函数在表设计时在 MS Access 365 中不可用
我试图简单地将文本字段转换为 MS Access 365 中的日期时间值。这应该很简单。但是我似乎无法访问 Date()、DateValue() 等函数。
我想要一些可以只传递一些文本并将其转换为日期时间类型的东西。我的数据如下所示:
我使用了公式:我使用这个公式得到了这个:Left$([DateText],InStr(1,[DateText]," - ")) 从 DateText 字段中删除时间。
现在我想使用 DateTextWithTimeRemoved 字段中的数据添加一个日期/时间类型的新字段。
,从几年前开始,我记得使用过 CDate() 或 Date() 或 DateValue() 等函数或其他函数,但它们就是不存在。我是否需要安装一些东西才能获得这些功能?
I'm trying to simply convert a text field into a datetime value in MS Access 365. This should be simple. However I don't seem to have access to functions like Date(), DateValue().
I want something where I can just pass some text in and it converts to a datetime type. My data looks like this:
I used the formula: I used this formula to get this: Left$([DateText],InStr(1,[DateText]," - "))
to remove the time from the DateText field.
Now I want to add a new field which is a date/time type using the data in the DateTextWithTimeRemoved field.
The table design view (also showing the conversion functions available) is like this:
And the date functions are these:
And so, from years ago I remember using functions like CDate() or Date() or DateValue() or what have you, but they're just not there. Do I have to install something to get these functions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您想保留问题中显示的相同表字段:
备份当前表。
将
DateThatIsAnActualDate
字段的数据类型更改为日期/时间,并将DateTextWithTimeRemoved
更改为短文本。创建更新查询。 (创建 -> 查询设计 -> 在查询类型下选择更新。)
添加表(成员)
Left([DateText],InStr(1,[DateText]," -"))
下一列
Format(DateValue(Left( [DateText],(InStr(1,[DateText]," -")))),"dd/mm/yyyy")
单击“运行”!
单击“是”进行确认。
全部完成。检查members表中的记录。
Assuming you want to keep the same Table fields shown in your question:
Make a backup of your current table.
Change the Data Type of the
DateThatIsAnActualDate
field to Date/Time andDateTextWithTimeRemoved
to Short Text.Create an an Update Query. (Create -> Query Design -> select Update under Query Type.)
Add your Table (members)
Left([DateText],InStr(1,[DateText]," -"))
next column
Format(DateValue(Left([DateText],(InStr(1,[DateText]," -")))),"dd/mm/yyyy")
Click Run !
Click Yes to confirm.
All done. Check the records in the members table.
首先,忘记计算字段。使用查询,这就是它们的用途。表格是用于数据的。
其次,表达式生成器毫无希望。我从来没有发现它有用。
接下来,轻松转换为真实日期值所需的只是删除破折号。
可以这样转换:
现在,您的查询可能如下所示:
注意,日期/时间值不带格式。将此应用仅用于显示,因此如果默认格式(Windows 设置的格式)不适合,请在需要时调整“格式”属性(查看数据的表单/报告)。
默认为:
First, forget about the calculated fields. Use queries, that's what they are for. Tables are for data.
Second, the Expression Builder is hopeless. I have never found it useful.
Next, all you need for an easy conversion to true date values, is to remove the dash.
This can be converted like this:
Now, your query could look this this:
Note, that date/time values carry no format. Apply this for display only, so adjust the Format property where needed (the forms/reports where you view the data), if the default format (that of your Windows settings) doesn't fit.
The default is: