DateDiff

G

Gee

Having trouble getting this to work.
I need the difference between "Estimated Complete Date"
and "Actual Complete Date" controls. Both are date format
and I need it to do the math when lost focus. I can't
seem to get the DateDiff syntax right.
Help?
Thank you,
Gee
 
G

Guest

Hi,
There is dificulty getting the datediff and dateadd
functions to wotk properly.
PLease look up KB article Q130514 and find related
articles.
The explanation is too long for this message.

Good luck.
Henning
 
G

Gee

Do you know if there any easy function to get the number
of days between startdate & enddate?
Do I have to use DateDiff to get this?
 
J

Jeff Conrad

Hi,

Try this as the Control Source for an unbound text box on
the form:

=DateDiff("d",[StartDate],[EndDate])

Replace with your actual field/control names.

Hope that helps,
Jeff Conrad
Bend, Oregon
 
J

John Vinson

Having trouble getting this to work.
I need the difference between "Estimated Complete Date"
and "Actual Complete Date" controls. Both are date format
and I need it to do the math when lost focus. I can't
seem to get the DateDiff syntax right.
Help?
Thank you,
Gee

Well... please post your code. It may be a bug as noted elsethread, or
you may have the syntax wrong - but since you didn't post the syntax
it's hard to tell what might be wrong!
 
G

Guest

Actually, I can't change the control source because I need
to link this particular control to queries & reports. Any
other ideas?
-----Original Message-----
Hi,

Try this as the Control Source for an unbound text box on
the form:

=DateDiff("d",[StartDate],[EndDate])

Replace with your actual field/control names.

Hope that helps,
Jeff Conrad
Bend, Oregon
-----Original Message-----
Do you know if there any easy function to get the number
of days between startdate & enddate?
Do I have to use DateDiff to get this?
.
 
G

Gee

I put this into LostFocus:

=DateDiff("d",[EstimatedCompleteDate],[ActualCompleteDate])
I tried it without the = and it still won't work.
Thanks for helping me, I really appreciate the time.
Gee
 
J

John Vinson

I put this into LostFocus:

=DateDiff("d",[EstimatedCompleteDate],[ActualCompleteDate])
I tried it without the = and it still won't work.
Thanks for helping me, I really appreciate the time.
Gee

It sounds like you'ld be better off putting the DateDiff expression in
a vacant Field cell in a Query. You could then use the calculated date
difference for searching, sorting, for display on a form or report, or
whatever.

Putting it in the LostFocus event will set the value of the LostFocus
event to the number of days... and Access will get VERY VERY confused!
 
G

Gee

Yeah, that will work, won't it! Thank you very much.
-----Original Message-----
I put this into LostFocus:

=DateDiff("d",[EstimatedCompleteDate], [ActualCompleteDate])
I tried it without the = and it still won't work.
Thanks for helping me, I really appreciate the time.
Gee

It sounds like you'ld be better off putting the DateDiff expression in
a vacant Field cell in a Query. You could then use the calculated date
difference for searching, sorting, for display on a form or report, or
whatever.

Putting it in the LostFocus event will set the value of the LostFocus
event to the number of days... and Access will get VERY VERY confused!


.
 
J

Jeff Conrad

Huh???

You should still be able to use the "content" of this text box for queries
and reports.
Why not make ANOTHER text box with the Control Source as already mentioned
just to display the number of days difference?
Heck you can even code a label to display the difference in days.

As John mentioned you could also use this in a query that becomes the record
source for the form or even use it on the report itself with an unbound text
box.

My "spidey" senses are telling me you're actually trying to SAVE the number
of days difference back to a table field. Is this the case??? If so, you
really shouldn't because it violates the Database Prime Directive: If
something can be calculated, don't save it. There are exceptions, but this
doesn't look like one.

Jeff Conrad
Bend, Oregon

Actually, I can't change the control source because I need
to link this particular control to queries & reports. Any
other ideas?
-----Original Message-----
Hi,

Try this as the Control Source for an unbound text box on
the form:

=DateDiff("d",[StartDate],[EndDate])

Replace with your actual field/control names.

Hope that helps,
Jeff Conrad
Bend, Oregon
-----Original Message-----
Do you know if there any easy function to get the number
of days between startdate & enddate?
Do I have to use DateDiff to get this?

-----Original Message-----
Hi,
There is dificulty getting the datediff and dateadd
functions to wotk properly.
PLease look up KB article Q130514 and find related
articles.
The explanation is too long for this message.

Good luck.
Henning

-----Original Message-----
Having trouble getting this to work.
I need the difference between "Estimated Complete Date"
and "Actual Complete Date" controls. Both are date
format
and I need it to do the math when lost focus. I can't
seem to get the DateDiff syntax right.
Help?
Thank you,
Gee
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

combine 2 functions 1
Calculating difference between dates 3
DateDiff Conditional Formating 2
Datediff on form and subform 6
Access DateDiff function 0
DateDiff Question 4
DateDiff 6
IF Statement Error 1

Top