Date Diff- weeks/days

A

Anne

I would like to display the difference between a specified date
[DateofInjury] and today, but in weeks and days. The following gives me the
weeks, but I would like the days as well.

=DateDiff("ww",[DateofInjury],Date())

I am sure this is easy, but eludes this novice...
 
M

Marshall Barton

Anne said:
I would like to display the difference between a specified date
[DateofInjury] and today, but in weeks and days. The following gives me the
weeks, but I would like the days as well.

=DateDiff("ww",[DateofInjury],Date())


Try this kind of thing:

DateDiff("d", DateofInjury, Date()) \ 7 * " weeks and " &
DateDiff("d", DateofInjury, Date()) Mod 7 * " days"
 
L

Linq Adams via AccessMonster.com

As marsh has shown, when using DateDiff() and wanting to return values in
more than one unit, days and weeks here, you have to find the difference in
the lowest common denominator (days in this case) then use math to parse it
into the individual units.

You'd do the same type of thing calculating money, converting dollars and
cents to cents (the lowest denominator) doing your addition or subtraction,
then parsing the answer back from cents to dollars and cents again.

Ditto for distances, and so forth.
 
A

Anne

Thanks Marsh!

To make it work all I changed was the * to an & before the string " weeks
and" and " days". That gave me exactly what I needed.

Perfect and so quick...

Marshall Barton said:
Anne said:
I would like to display the difference between a specified date
[DateofInjury] and today, but in weeks and days. The following gives me the
weeks, but I would like the days as well.

=DateDiff("ww",[DateofInjury],Date())


Try this kind of thing:

DateDiff("d", DateofInjury, Date()) \ 7 * " weeks and " &
DateDiff("d", DateofInjury, Date()) Mod 7 * " days"
 
L

Linq Adams via AccessMonster.com

Marsh's fingers apparently were greasy and kept slipping one key tp the right!
 
M

Marshall Barton

Linq said:
Marsh's fingers apparently were greasy and kept slipping one key tp the right!

Thanks for the excuse, Linq, but my fingers were not greasy.
I washed them right after I used a stick of cheese to train
the new puppy ;-) OTOH, my few remaining brain cells are
not all that well connected to my fumbly fingers so I often
miss the intended key.
 

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