Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#Error when applying DatePart function to a datetime field

Status
Not open for further replies.

galexy

Programmer
Mar 7, 2002
6
US
I have an Access database for which I need to write reporting software. One of the tables has datetime columns such as RingTime, HoldTime, TalkTime, which are supposed to contain the time each portion of a phone call took. I need to be able to do some calculations based on these columns. The problem is when I run a query, let's say:
Code:
SELECT TalkTime, DatePart('s', TalkTime) AS TalkTimeSec
FROM Connect
some of the rows return #Error in the TalkTimeSec column, while others return the correct answer. The corresponging TalkTime values, for which I get @Error, are 0:00:00, but not all 0:00:00 values produce #Error. An observation: when I am in datasheet view and I click in a cell containing 0:00:00 that doesn't produce #Error, the value doesn't change, but when I click in the cell that produces #Error, it changes from 0:00:00 to 12:00:00 AM as shown below.

If anyone has any idea, what the problem could be, please help. I spent a whole day trying to find a logical explanation and I wasn't successful.


query.gif

noerror.gif

error.gif
 
Some values seems to be null:
SELECT TalkTime, DatePart('s', Nz(TalkTime,0)) AS TalkTimeSec
FROM Connect

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
No, still doesn't work, showing the same result.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top