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

Date Diff Error

Status
Not open for further replies.

miletracker

Technical User
Apr 21, 2002
46
US
Can Someone help me with the following problem
I have a VB6 project with a access97 datasource I am tring to get the differance between 2 dates (in days) when I use the DateDiff function i get the following error "Data provider or other service returned an E_FAIL status"
If I try to do the expression by just "OutDate-InDate" (as in access)I get the following error "Your Entry cannot be converted to a valid date time value.
the Fields in access were set to "short date". I changed it to "medium date" but no help with a (00/00/00 mask) any help would be great
miletracker.
 
Show us the code where DateDiff function failed Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
DateDiff("d",OutDdate,InDate,,) where do i get jet 4.0
miletracker
 
Hey Anybody Am I all alone on this planet. I am still in need of a solution?????????????
miletracker (ps I saw the jet4.0 Web address)
 
where is this code at in your project? You've posted a pretty vague question,,, in order for people to provide a solution, you need to be a lot more specific and post a lot more than one line of code,,,
 
It is
not a problem in code. I am
trying to create a SQL Statement From The access table in Data Eviroment
 

Guys I am not at my PC all day so it seems a long time between replies please be patient with me this is not my REAL JOB.
Mile tracker
 
I am atempting to create a stored procedure or query on which to connect a data control and then a report or grid
is that impossible or is there a easier solution I am used to working with access so I am tring to do the same things miletracker
 
How is your table holding the dates? Are they Datetimes or are they strings?

Try this

sSQL = "SELECT DATEDIFF ( day, OutDate, InDate) FROM Blah"
 
first you retrive the two dates from the database.
And convert those to DATE format then pass these formatted dates to DateDiff function. This should be work.
if not just show ur code.
 
Ok guys I have this data that was collected in access OutDate refers to a column of Datetimes (shortdate) same as Indate and in access i would simply take date column minus the other to get the #of days. when i try to add the expression DateDiff("d",OutDate,InDate,,) in the SQL builder I got the error "Your Entry cannot be converted to a valid date time value".the error will not allow me to exit the expression until I delete the whole thing thanks for being patient with me
miletracker
 
Do a debug.Print of the Outdate to see what format it's in. Then use Format function to convert as required. SQL seems to always accept dates formatted with

Format(mydate,"dd/mmm/yyyy") Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top