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

I need to calc days between dates

Status
Not open for further replies.

angel769

Technical User
Jul 26, 2005
12
US
I need to know how many days there are between meter reads. I could have upto 6 read dates in one year, but i need to know the days between the first read and the last read. My report is grouped by the water meter and in the details section i have the read date. I have tried:

datediff("d",minimum({COMPRD.READDTTM}),Maximum({COMPRD.READDTTM}))

I have placed the formula in the header, details and footer, the results are all 362 days???

please Help!!!
 
YOu need to group by meter reading periods, is there a flag to differentiate?

If not group by meter reading date and use a date var

In Watermeter header

@reset
whileprintingrecords;

global datevar readingdate:= date(1900,01,01);


Split detail into 2 sections

In lower section (suppressed)

@startdate

whileprintingrecords;


global datevar readingdate:= Date(COMPRD.READDTTM);
// just incase COMPRD.READDTTM is datetime


In upper section

@Date diff
whileprintingrecords;

global datevar readingdate;

If readingdate = date(1900,01,01) then 0 else

datediff("d", readingdate, date(COMPRD.READDTTM))

Ian


 
Thank you Ian,

I had the report grouped my meter and just had to had the group qualifier to the formula and it worked!



datediff("d",minimum({COMPRD.READDTTM}, {COMPRD.COMPKEY}),Maximum({COMPRD.READDTTM}, {COMPRD.COMPKEY}))



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top