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

calculate days until today 1

Status
Not open for further replies.

karibai

Programmer
Nov 24, 2005
3
DE
Hello,
i'm a newbie with webfocus. The second report, I shall write, has to calculate with date. I have a field that contains a beginning date with timestamp. The format is A19. It looks like 2004-07-27-07.25.15.416780. I have to count the days from beginning date until "today". I don't know, how much reports I started without getting the right solution! Can you help me, please?
Thanks
Karin
 
Here's an example of how to do it. First, strip out the 'date' from the date-time stamp, using the EDIT function, then, use the YMD function, which calculates the difference between two legacy dates, in [Y]YMD format. To automatically insert today's date, use &YYMD.

If you're dealing with 'smart' dates, you can just subtract two dates to get the difference.

As an aside, the string you gave was 26 characters long; it won't fit into an A19.

Code:
DEFINE FILE CAR
-* the next line is just to get the value into a field
XDT/A26='2004-07-27-07.25.15.416780';
ADT/A8YYMD=EDIT(XDT,'9999$99$99');
DATEDIFF/I6 = YMD(ADT,'&YYMD');
END
TABLE FILE CAR
PRINT XDT ADT DATEDIFF
WHERE COUNTRY EQ 'ENGLAND'
END
 
Hi focwizard,
great! It works!
Thanks
Karin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top