View Full Version : Due date field


Stewart Spiers
01-30-2005, 03:26 AM
After entering a date in a character field is it possible to write a script to display a due date in another field, next month for example. If so how to I do this??

Stewart Spiers

Tom Cone Jr
01-30-2005, 03:55 AM
Read the manual for information on date arithmetic. You could define a calc field in field rules for the due date using an expression that adds a fixed number of days to the other date field value.

-- t

Jay Talbott
01-30-2005, 04:55 AM
In my humble opinion, you are asking for trouble using a character field to gather date information. If the user type Febary 1, 2005, or 2/31/05, for example, how will your program know what date the user wants.

You should use a date field for dates.

I hope this helps.

Jay Talbott

Bill Warner
01-30-2005, 05:15 AM
I agree wholeheartedly with Jay. Use date fields!

Here are some examples of date math:

DATE2 = DATE1 + 15

will add 15 days to DATE1 to give DATE2


will add one month to DATE1 (i.e., the same day of the month - Jan 27 to Feb 27). Be careful with this when dealing with February!

Tom Cone Jr
01-30-2005, 01:13 PM
I agree. In my previous I missed the fact that a character type field is being used. A bad business, in my opinion. Date arithmetic, obviously, requires date type fields.

-- t

Stewart Spiers
01-31-2005, 12:54 AM
I have made 2 new Date fields, Date1 and Date 2

I have tried entering your suggestions, Date2 = Addmonths(1,1) or Date2 = Date1+15 but each time I am told “Expression does not evaluate to a numeric value".

Please advise

Stewart Spiers

Tom Cone Jr
01-31-2005, 03:09 AM

when someone offers a suggestion to you and it involves a function you're not familiar with it's wise to read the docs to "decode" what the suggestion is doing. If you review the help file info on the AddMonths() function you'll quickly see that the first argument that is passed to the function must be a date. AddMonths(1,1) is invalid since the first "1" is not a date.

Try AddMonths(Date1, 1)

The attachment is a simple example I whipped up for you. It shows how to do this in field rules for a table. Unzip the attachment to an empty folder. enter a few records, change a few. Study the field rules. Lookup the pieces you don't understand. Then, finally, integrate it into your app.

-- tom

Stewart Spiers
02-01-2005, 12:57 AM
Thanks for trying to help me.

Unfortunately when trying to run your example it says it was written with the Professional Edition of Alpha5 and cannot open it as I use the Home Edition of Alpha5

Is there a way around that problem

Stewart Spiers

Tom Cone Jr
02-01-2005, 02:14 AM
Next time please mention that you're using the Home Edition up front.

The fix is easy.

Use Windows Explorer to copy the Test table and its dictionaries to a new folder.

Use the home edition to create a new database in that same new folder and then "Add" the Test table to it.

Use the default form or browse to enter and change a few records.

Then study the field rules for the Test table.

-- t

Tom Cone Jr
02-01-2005, 02:20 AM
An even easier fix would be to simple open the home editioin and create a new database in the current folder (where you unzipped the original download). then add the Test table to that database.

-- t

Stewart Spiers
02-02-2005, 12:20 AM
Thanks very much now it all works.

I would love to be able to study the field rules but cannot find any article in the instruction books relating to dates which says anything about how to write the program you have sent me.

Is this because I only have the home edition of Alpha5

Where should I look

Stewart Spiers

Tom Cone Jr
02-02-2005, 12:51 AM
The best source of technical "help" is the compiled help file (CHM) called "Alpha Five Help", available as a free,large, download from the Learning Center. The link to the LC is on the Alpha Software home page.

I recommend you buy and study all 3 of Dr. Wayne's books if you'd like to learn how to use Alpha Five more effectively.

If you haven't worked through the free tutorials, that's higly recommended, also.

In the file I sent you I created a single field rule, for the Due_Date field. It uses a single expression to calculate the value to store in Due_Date, by adding one month to the Bill_Date field. If you haven't found the field rules for the table you should work through the user's guide before doing anything else.

-- t