SQL-only find time and not date in Access Date/Time field

我的未来我决定 提交于 2019-12-02 12:28:04

问题


In an Access database table some Date/Time data has corrupted and now only shows a time e.g. 15:15. Is there any SQL that will allow me to select records which only have the time data and not any date data in?

i have tried this, but it doesn't work

select datetimefield
from table
WHERE IsDate(datetimefield) = 0

回答1:


Access does not have separate Date and Time column (field) types, so it does two things to "help" users work with "dates" and "times":

  1. Date/Time values where the time is exactly midnight will by default be displayed as just the date.

  2. Date/Time values where the date part is 1899-12-30 will by default be displayed as just the time.

In these special cases the full Date/Time information can be displayed by specifically formatting the value (using the .Format properties of fields or controls, or by using the Format() function).

So, to select Date/Time values that look like they only contain times you would do

SELECT datetimevalue
FROM tablename
WHERE datetimevalue >= #1899-12-30# AND datetimevalue < #1899-12-31#


来源:https://stackoverflow.com/questions/26587468/sql-only-find-time-and-not-date-in-access-date-time-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!