For Ken Sheridan re rounding DateDiff

C

CW

Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate], [ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England
I am using DateDiff with "w" to produce the result in weeks, which is then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW
 
C

Clif McIrvin

CW said:
Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I
can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate],
[ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England
I am using DateDiff with "w" to produce the result in weeks, which is
then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW

I'm not Ken; but something I saw from John Vinson a few days ago might
work here:

<q>
There's a cute trick that depends on the way the Int() function treats
negative numbers - Int(3.3) becomes 3, but Int(-3.3) becomes -4. So

XRoundedUp: -Int(-[X])

will work for you. If the field X is 3.3, XRoundedUp will be displayed
as 4.


John W. Vinson [MVP]
</q>

so try:

= - int( - DateDiff("w",[FromDate],[ToDate]) )

(spaces added for clarity)

HTH!
 
C

CW

Thanks Clif/Ken...
Sadly it is still not rounding up.
My two date fields are (in UK format) 01/01/2009 and 31/03/2009. Having
studied the calendar several times I am happy that the interval is 13 weeks.
However the expression you suggested, Clif:
= - int( - DateDiff("w",[FromDate],[ToDate]) )
insists that it is only 12 weeks!
We charge "per week or part thereof" so it is really important that I get
this rounding up sorted out.
All further suggestions welcome!!
Many thanks
CW

Clif McIrvin said:
CW said:
Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I
can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate],
[ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England
I am using DateDiff with "w" to produce the result in weeks, which is
then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW

I'm not Ken; but something I saw from John Vinson a few days ago might
work here:

<q>
There's a cute trick that depends on the way the Int() function treats
negative numbers - Int(3.3) becomes 3, but Int(-3.3) becomes -4. So

XRoundedUp: -Int(-[X])

will work for you. If the field X is 3.3, XRoundedUp will be displayed
as 4.


John W. Vinson [MVP]
</q>

so try:

= - int( - DateDiff("w",[FromDate],[ToDate]) )

(spaces added for clarity)

HTH!
 
C

Clif McIrvin

Afraid I'm showing my ignorance .... DateDiff doesn't return fractional
values, does it?

Gosh -- it seemed like such a nice idea, too.

--
Clif
Still learning Access 2003

so try:

= - int( - DateDiff("w",[FromDate],[ToDate]) )

(spaces added for clarity)

HTH!
 
J

John Spencer (MVP)

Perhaps you can use this expression
-Int(-DateDiff("d",[FromDate],[ToDate])/7)

You may need to adjust that to account for the first day
-Int(-(DateDiff("d",[FromDate],[ToDate])+1)/7)


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
C

Clif McIrvin

CW said:
Thanks Clif/Ken...
Sadly it is still not rounding up.
My two date fields are (in UK format) 01/01/2009 and 31/03/2009.
Having
studied the calendar several times I am happy that the interval is 13
weeks.
However the expression you suggested, Clif:
= - int( - DateDiff("w",[FromDate],[ToDate]) )
insists that it is only 12 weeks!
We charge "per week or part thereof" so it is really important that I
get
this rounding up sorted out.
All further suggestions welcome!!
Many thanks
CW

(See my second post ... sorry for the bum advice.)

Back to Ken's original suggestion:

=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate],
[ToDate])
Mod 7 > 0,1,0)


I think line wrap got you .... look at it like this:

=DateDiff("w",[FromDate], [ToDate])
+ IIf(DateDiff("d",[FromDate], [ToDate])
Mod 7 > 0,1,0)

but make certain it's all on one line. Think of it like this:

<example only>

DaysDiff = DateDiff("d",[FromDate], [ToDate])

WeeksWithFraction = DaysDiff Mod 7

WeeksRoundedUp = DateDiff("w",[FromDate], [ToDate])
+ IIf( WeeksWithFraction > 0,1,0)

</example>

HTH
 
D

Douglas J. Steele

DateDiff counts "changes in boundaries". The boundary for weeks is the next
occurrence of the same weekday as the first date. January 1 was a Thursday,
Calculating the number of weeks between Jan 1 and Jan 2 results in 0, as
will calculating the number of weeks between Jan 1 and Jan 3, Jan 4, Jan 5,
Jan 6 and Jan 7. It's not until you hit the next Thursday (Jan 8) that
you'll 1 week. Similarly, Jan 1 to Jan 15 (the next Thursday) will be the
first comparison yielding 2 weeks, Jan 1 to Jan 22 will be the first
comparison yielding 3 weeks and so on. It's 12 weeks between Jan. 1 and Mar
26, and won't be 13 weeks until Apr 2, the next Thursday.

Perhaps you need to calculate the number of days divided by 7.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


CW said:
Thanks Clif/Ken...
Sadly it is still not rounding up.
My two date fields are (in UK format) 01/01/2009 and 31/03/2009. Having
studied the calendar several times I am happy that the interval is 13
weeks.
However the expression you suggested, Clif:
= - int( - DateDiff("w",[FromDate],[ToDate]) )
insists that it is only 12 weeks!
We charge "per week or part thereof" so it is really important that I get
this rounding up sorted out.
All further suggestions welcome!!
Many thanks
CW

Clif McIrvin said:
CW said:
Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I
can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate],
[ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England

:

I am using DateDiff with "w" to produce the result in weeks, which is
then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW

I'm not Ken; but something I saw from John Vinson a few days ago might
work here:

<q>
There's a cute trick that depends on the way the Int() function treats
negative numbers - Int(3.3) becomes 3, but Int(-3.3) becomes -4. So

XRoundedUp: -Int(-[X])

will work for you. If the field X is 3.3, XRoundedUp will be displayed
as 4.


John W. Vinson [MVP]
</q>

so try:

= - int( - DateDiff("w",[FromDate],[ToDate]) )

(spaces added for clarity)

HTH!
 
C

Clif McIrvin

<snip>

I still didn't get it right ... I'd better quit playing with VBA and go
back to breaking concrete ... I know how to do that <grin>

What I did wrong in this post was an incorrect understanding of the Mod
operator - so my example wasn't accurate.
WeeksWithFraction = DaysDiff Mod 7
is wrong.

WeeksWithFraction = DaysDiff / 7
-or-
DaysInPartialWeek = DaysDiff Mod 7

would be more correct.

(John Spencer - thanks for jumping in!)

I <think> I got things right this time.

--
Clif
=DateDiff("w",[FromDate], [ToDate])
+ IIf(DateDiff("d",[FromDate], [ToDate])
Mod 7 > 0,1,0)

but make certain it's all on one line. Think of it like this:

<example only>

DaysDiff = DateDiff("d",[FromDate], [ToDate])

WeeksWithFraction = DaysDiff Mod 7

WeeksRoundedUp = DateDiff("w",[FromDate], [ToDate])
+ IIf( WeeksWithFraction > 0,1,0)

</example>

HTH
 
C

CW

Never mind Clif, thanks for trying to help!

Clif McIrvin said:
Afraid I'm showing my ignorance .... DateDiff doesn't return fractional
values, does it?

Gosh -- it seemed like such a nice idea, too.

--
Clif
Still learning Access 2003

so try:

= - int( - DateDiff("w",[FromDate],[ToDate]) )

(spaces added for clarity)

HTH!
 
C

CW

Thanks Doug, I was just about coming round to that conclusion myself. And
then I'll round up the week-count that comes out of that calculation.
Thanks
CW

Douglas J. Steele said:
DateDiff counts "changes in boundaries". The boundary for weeks is the next
occurrence of the same weekday as the first date. January 1 was a Thursday,
Calculating the number of weeks between Jan 1 and Jan 2 results in 0, as
will calculating the number of weeks between Jan 1 and Jan 3, Jan 4, Jan 5,
Jan 6 and Jan 7. It's not until you hit the next Thursday (Jan 8) that
you'll 1 week. Similarly, Jan 1 to Jan 15 (the next Thursday) will be the
first comparison yielding 2 weeks, Jan 1 to Jan 22 will be the first
comparison yielding 3 weeks and so on. It's 12 weeks between Jan. 1 and Mar
26, and won't be 13 weeks until Apr 2, the next Thursday.

Perhaps you need to calculate the number of days divided by 7.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


CW said:
Thanks Clif/Ken...
Sadly it is still not rounding up.
My two date fields are (in UK format) 01/01/2009 and 31/03/2009. Having
studied the calendar several times I am happy that the interval is 13
weeks.
However the expression you suggested, Clif:
= - int( - DateDiff("w",[FromDate],[ToDate]) )
insists that it is only 12 weeks!
We charge "per week or part thereof" so it is really important that I get
this rounding up sorted out.
All further suggestions welcome!!
Many thanks
CW

Clif McIrvin said:
Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I
can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate],
[ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England

:

I am using DateDiff with "w" to produce the result in weeks, which is
then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW


I'm not Ken; but something I saw from John Vinson a few days ago might
work here:

<q>
There's a cute trick that depends on the way the Int() function treats
negative numbers - Int(3.3) becomes 3, but Int(-3.3) becomes -4. So

XRoundedUp: -Int(-[X])

will work for you. If the field X is 3.3, XRoundedUp will be displayed
as 4.


John W. Vinson [MVP]
</q>

so try:

= - int( - DateDiff("w",[FromDate],[ToDate]) )

(spaces added for clarity)

HTH!
 
C

CW

Hallelujah!
Found the final bit that I needed, here: http://allenbrowne.com/round.html
What that man doesn't know about Access isn't worth knowing!!
Thanks for all the help
CW

CW said:
Never mind Clif, thanks for trying to help!

Clif McIrvin said:
Afraid I'm showing my ignorance .... DateDiff doesn't return fractional
values, does it?

Gosh -- it seemed like such a nice idea, too.

--
Clif
Still learning Access 2003

so try:

= - int( - DateDiff("w",[FromDate],[ToDate]) )

(spaces added for clarity)

HTH!
 
K

Ken Sheridan

Clif:

Its not simply that your newsreader has split the expression, and you are
entering as two lines by any chance? That's a not uncommon gotcha in
newsgroups. The whole expression must be entered as one line in the
ControlSource property.

The expression certainly works, and as the field names are the same in your
simple expression a in my more complex one, then it can't be something like a
misspelt name that's causing the error.

If you need to compute the weeks difference elsewhere in the database then
it might be worth writing a little function in a standard module:

Public Function WeeksDiffRoundedUp(dtmFrom As Date, _
dtmTo As
Date) As Integer

WeeksDiffRoundedUp = _
DateDiff("w", dtmFrom, dtmTo) _
+ IIf(DateDiff("d", dtmFrom, dtmTo) Mod 7 > 0, 1, 0)

End Function

Note that in this case the expression really is split over three lines by
means of the underscore continuation characters and should be entered as
such, as should the function declaration which is also split over two lines
with the underscore continuation character. This makes for easier
readability in the VBA window as well as preventing any confusing line breaks
here.

You can then call it as the ControlSource property of a control on your form
with:

=WeeksDiffRoundedUp([FromDate], [ToDate])

or anywhere else in the database, e.g. as a computed column in a query.

Ken Sheridan
Stafford, England

CW said:
Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate], [ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England
I am using DateDiff with "w" to produce the result in weeks, which is then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW
 
C

CW

Ken -
Thanks for coming back on this. You mention the splitting of the expression
by the newsreader, and that certainly did happen, but when entering it into
the control source I was careful to place the whole of it in there. However,
and I did this several times, after I had re-tested the form and found it
didn't work, then went back into the control, it had dropped all the
expression from Mod 7 onwards! I re-entered that bit manually and tried
again, and the same thing happened, several times. That's the point at which
I posted back asking if you had any further ideas.
Anyway eventually I achieved what I wanted, via a rather clunky arrangement
of hidden controls calculating the interval firstly into days, then another
one that divided that by 7, and finally I used Allen Browne's tip to ensure
that the rounding worked correctly.
I have jotted down the function that you have just recommended and I will
certainly try that elsewhere in the mdb as we have quite a few date/time
calculations to deal with.
Many thanks
CW

Ken Sheridan said:
Clif:

Its not simply that your newsreader has split the expression, and you are
entering as two lines by any chance? That's a not uncommon gotcha in
newsgroups. The whole expression must be entered as one line in the
ControlSource property.

The expression certainly works, and as the field names are the same in your
simple expression a in my more complex one, then it can't be something like a
misspelt name that's causing the error.

If you need to compute the weeks difference elsewhere in the database then
it might be worth writing a little function in a standard module:

Public Function WeeksDiffRoundedUp(dtmFrom As Date, _
dtmTo As
Date) As Integer

WeeksDiffRoundedUp = _
DateDiff("w", dtmFrom, dtmTo) _
+ IIf(DateDiff("d", dtmFrom, dtmTo) Mod 7 > 0, 1, 0)

End Function

Note that in this case the expression really is split over three lines by
means of the underscore continuation characters and should be entered as
such, as should the function declaration which is also split over two lines
with the underscore continuation character. This makes for easier
readability in the VBA window as well as preventing any confusing line breaks
here.

You can then call it as the ControlSource property of a control on your form
with:

=WeeksDiffRoundedUp([FromDate], [ToDate])

or anywhere else in the database, e.g. as a computed column in a query.

Ken Sheridan
Stafford, England

CW said:
Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate], [ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England
I am using DateDiff with "w" to produce the result in weeks, which is then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW
 
K

Ken Sheridan

I'm wondering whether its really has dropped the 'Mod 7 > 0, 1, 0)' part of
the expression, but its in fact not showing because its on another line. Its
interesting that here I'm seeing the line break at that point. So when you
enter the it manually you in fact end up with that part of the expression
twice separated by a carriage return/line feed. That would account for the
error. You'd be able to check this by 'zooming' the ControlSource property
in the properties sheet, so you see it in a window rather than just on the
one line. The expression itself is fine, but there must be some explanation
fro the error.

Ken Sheridan
Stafford, England

CW said:
Ken -
Thanks for coming back on this. You mention the splitting of the expression
by the newsreader, and that certainly did happen, but when entering it into
the control source I was careful to place the whole of it in there. However,
and I did this several times, after I had re-tested the form and found it
didn't work, then went back into the control, it had dropped all the
expression from Mod 7 onwards! I re-entered that bit manually and tried
again, and the same thing happened, several times. That's the point at which
I posted back asking if you had any further ideas.
Anyway eventually I achieved what I wanted, via a rather clunky arrangement
of hidden controls calculating the interval firstly into days, then another
one that divided that by 7, and finally I used Allen Browne's tip to ensure
that the rounding worked correctly.
I have jotted down the function that you have just recommended and I will
certainly try that elsewhere in the mdb as we have quite a few date/time
calculations to deal with.
Many thanks
CW

Ken Sheridan said:
Clif:

Its not simply that your newsreader has split the expression, and you are
entering as two lines by any chance? That's a not uncommon gotcha in
newsgroups. The whole expression must be entered as one line in the
ControlSource property.

The expression certainly works, and as the field names are the same in your
simple expression a in my more complex one, then it can't be something like a
misspelt name that's causing the error.

If you need to compute the weeks difference elsewhere in the database then
it might be worth writing a little function in a standard module:

Public Function WeeksDiffRoundedUp(dtmFrom As Date, _
dtmTo As
Date) As Integer

WeeksDiffRoundedUp = _
DateDiff("w", dtmFrom, dtmTo) _
+ IIf(DateDiff("d", dtmFrom, dtmTo) Mod 7 > 0, 1, 0)

End Function

Note that in this case the expression really is split over three lines by
means of the underscore continuation characters and should be entered as
such, as should the function declaration which is also split over two lines
with the underscore continuation character. This makes for easier
readability in the VBA window as well as preventing any confusing line breaks
here.

You can then call it as the ControlSource property of a control on your form
with:

=WeeksDiffRoundedUp([FromDate], [ToDate])

or anywhere else in the database, e.g. as a computed column in a query.

Ken Sheridan
Stafford, England

CW said:
Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate], [ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England

:

I am using DateDiff with "w" to produce the result in weeks, which is then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW
 
C

CW

Ah, a definite touch of the Poirots there...yes that was exactly it - I
zoomed in and cleaned up the control source and it worked absolutely fine. I
adjusted the dates up and down and it calculated the rounding perfectly just
when/how it should.
Good stuff, thank you very much
CW


Ken Sheridan said:
I'm wondering whether its really has dropped the 'Mod 7 > 0, 1, 0)' part of
the expression, but its in fact not showing because its on another line. Its
interesting that here I'm seeing the line break at that point. So when you
enter the it manually you in fact end up with that part of the expression
twice separated by a carriage return/line feed. That would account for the
error. You'd be able to check this by 'zooming' the ControlSource property
in the properties sheet, so you see it in a window rather than just on the
one line. The expression itself is fine, but there must be some explanation
fro the error.

Ken Sheridan
Stafford, England

CW said:
Ken -
Thanks for coming back on this. You mention the splitting of the expression
by the newsreader, and that certainly did happen, but when entering it into
the control source I was careful to place the whole of it in there. However,
and I did this several times, after I had re-tested the form and found it
didn't work, then went back into the control, it had dropped all the
expression from Mod 7 onwards! I re-entered that bit manually and tried
again, and the same thing happened, several times. That's the point at which
I posted back asking if you had any further ideas.
Anyway eventually I achieved what I wanted, via a rather clunky arrangement
of hidden controls calculating the interval firstly into days, then another
one that divided that by 7, and finally I used Allen Browne's tip to ensure
that the rounding worked correctly.
I have jotted down the function that you have just recommended and I will
certainly try that elsewhere in the mdb as we have quite a few date/time
calculations to deal with.
Many thanks
CW

Ken Sheridan said:
Clif:

Its not simply that your newsreader has split the expression, and you are
entering as two lines by any chance? That's a not uncommon gotcha in
newsgroups. The whole expression must be entered as one line in the
ControlSource property.

The expression certainly works, and as the field names are the same in your
simple expression a in my more complex one, then it can't be something like a
misspelt name that's causing the error.

If you need to compute the weeks difference elsewhere in the database then
it might be worth writing a little function in a standard module:

Public Function WeeksDiffRoundedUp(dtmFrom As Date, _
dtmTo As
Date) As Integer

WeeksDiffRoundedUp = _
DateDiff("w", dtmFrom, dtmTo) _
+ IIf(DateDiff("d", dtmFrom, dtmTo) Mod 7 > 0, 1, 0)

End Function

Note that in this case the expression really is split over three lines by
means of the underscore continuation characters and should be entered as
such, as should the function declaration which is also split over two lines
with the underscore continuation character. This makes for easier
readability in the VBA window as well as preventing any confusing line breaks
here.

You can then call it as the ControlSource property of a control on your form
with:

=WeeksDiffRoundedUp([FromDate], [ToDate])

or anywhere else in the database, e.g. as a computed column in a query.

Ken Sheridan
Stafford, England

:

Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate], [ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England

:

I am using DateDiff with "w" to produce the result in weeks, which is then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW
 
H

Howard Burgman

CW said:
Ken -
Thanks for the solution you suggested on 3rd Jan but unforunately I can't
get this to work... I get #Error...
Any further suggestions, please?
Many thanks
CW

:
Try this:
=DateDiff("w",[FromDate], [ToDate]) + IIf(DateDiff("d",[FromDate],
[ToDate])
Mod 7 > 0,1,0)
Ken Sheridan
Stafford, England
I am using DateDiff with "w" to produce the result in weeks, which is then
used as the chargeable period for the storage of goods.
We charge "per week or part", therefore I would like the result to be
rounded up.
My expression looks like this at the moment:
=DateDiff("w",[FromDate],[ToDate])
How should I modify this to get a rounded-up figure, please?
Many thanks
CW
 
V

Vossen

Geen mails meer sturen afmelden


Op 16-01-2009 19:10, in artikel
(e-mail address removed), CW
Hallelujah!
Found the final bit that I needed, here: http://allenbrowne.com/round.html
What that man doesn't know about Access isn't worth knowing!!
Thanks for all the help
CW

CW said:
Never mind Clif, thanks for trying to help!

Clif McIrvin said:
Afraid I'm showing my ignorance .... DateDiff doesn't return fractional
values, does it?

Gosh -- it seemed like such a nice idea, too.

--
Clif
Still learning Access 2003


so try:

= - int( - DateDiff("w",[FromDate],[ToDate]) )

(spaces added for clarity)

HTH!
 

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

Top