DateDiff

  • Thread starter Thread starter Gee
  • Start date Start date
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
 
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
 
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?
 
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
 
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!
 
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?
.
 
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
 
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!
 
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!


.
 
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
.
 
Back
Top