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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using datediff on text field in query

Status
Not open for further replies.

mssbass

IS-IT--Management
Aug 24, 2001
53
0
0
US
Is there a way for a query to recognize a text field as a date? My query:

DateDiff("s","ExpectedDeliverDate","ActualDeliverDate")

error: data type mismatch
 
What are ExpectedDeliverDate and ExpectedDeliverDate ?
My guess:
DateDiff('s',[ExpectedDeliverDate],[ActualDeliverDate])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The expecteddeliverdate and actualdeliverdate are in the following format:

2005-10-06 23:59:00.000

However, these are text values - it won't subtract since they aren't a date value using the datediff function...
 
And what about this ?
DateDiff('s',CDate(Left(ExpectedDeliverDate,InStr(ExpectedDeliverDate,'.')-1)),CDate(Left(ActualDeliverDate,InStr(ActualDeliverDate,'.')-1)))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Excellent - Thank you sooooooooooo much:)
 
Oh yeah - how do I give the restraint as follows:

>0

"It must be greater than 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top