问题
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":
Date/Time values where the time is exactly midnight will by default be displayed as just the date.
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