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!

How to project "due date" from date field

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I serve clients from 2 agencies. One requires that I turn in reports 10 BUSINESS days after seeing their client. The other requires 15 CALENDAR days. Is there a way to put a date calc field into my database that will get this date for me based upon the date in a field called "DATESEEN"?
 
Easy bit first. For the second Client, it is ReportDue = date(DateSeen) + 15

First client is a bit more tricky if you have to take public holidays into account. If not, and assuming Sat+Sun are non business days, then

switch
case dow(date(DateSeen)) = "Sat" : ReportDue = date(DateSeen) + 13
case dow(date(DateSeen)) = "Sun" : ReportDue = date(DateSeen) + 12
otherwise : ReportDue = date(DateSeen) + 14
endSwitch

If you need to take holidays into account then you will have to use a table which depends on the relevant country and increment ReportDue if a holiday falls between DateSeen and the above ReportDue date (and there may be more than one holiday!!)
(Tip: with a bit of fiddling, you can use MS Outlook to generate a suitable 'holiday' table)
 
Daniel,

Also, see my reply to the same question on wpuniverse.

-- Lance
 
Thanks so much for the reply about report due dates. One follow up question...where do I insert that code if I use p9 interactively? I can tinker and get it to work if I know where to put it.

Dan
 
Depends on what you already have on your form and whether or not you intend to add a new field to your table. If you are only displaying one record at a time, then you will get away with adding an unbound field to the form and placing the code in the action method of the page. If you are using a tableframe or MRO then I suggest that you add a ReportDue field to the table and put the code in a pushbutton to populate ReportDue just before you commit records to the table.
 
Ogriofa...

I tried as best I could to understand what you were telling me to do, but got an error message...something like "identifier expected" or some such. Here's what I did:

1. I went into the form..copied a field that had a date in it. Then...renamed the field label to "DayTen".

2. Then...I defined the field with one long line with the info you gave me...except I filled in the correct field name and the renamed field label..such that the resulting text was as follows (one long line):


========================================================
switch case dow(date(Appt Date)) = "Sat" : DayTen = date(Appt Date) + 13 case dow(date(Appt Date)) = "Sun" DayTen = date(Appt Date) + 12 otherwise : DayTen = date(Appt Date) + 14 endSwitch
==========================================================

Appt Date is the field in the database that holds the the
date that I am scheduled to see the client. DayTen is the field whose label (on the form) I changed from what it used to be (Appt Date) to what I HOPED would hold the calculated field information on the south side of the code you gave me above.

As you can tell from this note...I'm not too sophisticated with p9. I'm not a programmer. Can you tell me if I'm leaving something out in the code you gave me?

Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top