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

difference between two dates in Weeks and Days please ?

Status
Not open for further replies.

TaTips

Programmer
Oct 29, 2003
25
0
0
GB
Hi:

can anyone suggest how to calculate the difference between two dates in Weeks and Days please ?

Eg.

3 Weeks 2 Days

Thanks.
Ta.
 
Try this, replace the items in bold with your real dates....

Local NumberVar NumofDays := DateDiff("d",Date(2004,01,01),Date(2004,01,22))+1;
ToText(NumofDays/7,0)&" week(s) "&ToText(NumofDays-(Int(NumofDays/7)*7),0)&" day(s)"

Reebo
 
Thanks for reply reboo but I dont think its quite there. i may be wrong though.

My dates are 04-JUN-2004 and 01-JUL-2004:

This makes it 26 days in total the formula returns 4 Weeks and 3 days.

I make it 26/7 = 3 Weeks and 5 Days.

Not sure here.

Thanks.
ta.

 
Try:

totext(truncate(datediff("d",date(2004,06,04),date(2004,07,01))/7,0),0,"")+" Weeks " + totext(remainder(datediff("d",date(2004,06,04),date(2004,07,01)),7)-1,0,"")+" Days"

-LB
 
TaTips,

In future, you need to specify your requirements a bit more clearly.

You want the difference between 2 dates, Not including the 2 dates specified, is this correct?

If so, use:

Local NumberVar NumofDays := DateDiff("d",Date(2004,06,04),Date(2004,07,01))-1;
ToText(Truncate(NumofDays/7),0)&" week(s) "&ToText(NumofDays-(Int(NumofDays/7)*7),0)&" day(s)"

The solution I provided originally, gave you the difference including the 2 dates.

Reebo
 
Thanks Reboo and Everyone else.

Tatips
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top