数字“日期” 在数据库中 - 如何使用“正常”与数据库进行交互 日期?
我正在使用这个数据库,其中日期列是数值而不是日期值。
是的,我知道我可以通过单击鼠标来更改它,但是使用该数据库的所有应用程序都是由我的一位前任创建的(他之后的每个人都忽略了它并继续构建)。 因此,如果我将其更改为“日期”,很多 af 应用程序都会失败。 :(
嗯,我正在对该数据库进行概述,从一个特定日期到另一个特定日期。我尝试使用下拉列表,但正如您所知,一个列表中的一千个选项非常不方便,甚至丑陋。
我宁愿有小日-月-年的输入字段,但是数据库中的数字日期出现了华尔兹,我必须以某种方式将日期计算回数字值......
一定有一个简单的解决方案,对吗?
我使用 ASP(vbscript) 作为应用程序,它用于内部网络,并且我有一个 Access 数据库。
I'm using this database where the date colomn is a numeric value instead of a Date value.
Yes, I know I can change that with a mouseclick, but all the applications using that database were made by one of my predecessors (and everyone after him just ignored it and built on). So if I'd change it to Date a lot af applications would fail. :(
Well, I am making an overview of that database, ranging from one specfic date to another. I tried using a dropdown list but as you can tell, a thousand options in one list is terribly inconvenient, even ugly.
I rather have small inputfields for day - month - year, but there comes waltzing in the numeric date in the database. I would have to calculate the date back to the numeric value somehow...
There must be an easy solution to this. Right?
I'm using ASP(vbscript) for the application, it's for an intraweb, and I have an Access Database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Access 将为您转换为数字,如前所述,日期存储为数字。
编辑评论:这是一个小测试,显示返回的日期:
Access will convert to a number for you, as was mentioned, the dates are stored as numbers.
EDIT re comment: Here is a small test that shows dates returned:
是的..所以这真的很容易。 我会接受 Remou 的回答, WHERE NumberDate= #2008/12/7# 可以解决问题。
但是,为了结束这个问题,这是我自己摆弄 Functions:
输出的解决方案:
它使得 31/12/1899 不是第 0 天,而是第 1 天。 :/
多谢你们!
Right.. so it was real easy. I'll accept Remou's answer, the WHERE NumberDate= #2008/12/7# does the trick.
But, to put a close to the matter, here's the solution to my own fiddling with Functions:
output:
It's made it so that 31/12/1899 is not day Zero, but day One. :/
Thanks guys!
Access 在内部将日期存储为浮点数(自 1899 年 12 月 31 日以来的天数或其他),您是否尝试过使用 CDate() 将数字转换回日期? 然后您应该能够使用 BETWEEN 进行查询。
另一种可能性是日期以数字形式存储但未转换(即 31121899),在这种情况下,您应该能够使用 Format() 或 Day() 或 Month() 或 Year() 获取适当的日期部分。
希望这可以帮助。
Access stores date internally as a floating point number (number of days since 31.12.1899 or something), have you tried using CDate() to convert the number back to a date? You should be able to query using BETWEEN then.
Another possibility is that the date is stored numerically but not converted (i.e 31121899), in this case you should be able to get the appropriate date parts using either Format() or Day() or Month() or Year().
Hope this helps.
遗憾的是,日期存储为 39791 -> 2008 年 12 月 9 日。 浮点数。
我有一个 javascript 函数(也是由同一前辈编写的),可以将日期转换为可读格式。 这是相反的方式,回到那个让我困惑的数值的方式。
Sadly the date is stored as 39791 -> 9-dec-2008. The floating point number.
I have a javascript function (also written by the same predecessor) that convertes the date to a readable format. It's the other way around, the way back to that numeric value that baffles me.