Topic: ADD Days

Hello,
i am a Beginner, and dont have a long  experience with  databases :§

i have a small Problem .
im My CALO Table there are 4 Fields for *Description, Period, Caldate, Duedate) and the Duedate should be= Caldate +Period , and the database has to do that automatically , i made a Button with SQL query to do that and it works good but when i search for my calculated Duedate i cant find  it   .
this is the  SQL query
UPDATE CALO
SET  Duedate = DATE(Caldate,'+365 Day')
where Period =365;

Thanks in advance for the help

Re: ADD Days

Hello sahems.y.3


The calculated field you have set in you database via MVD is not an actual field.


It appears when you want to setup a TableGrid in the list of available fields, but if you open the database file, you will notice that there is no actual storing of the calculated value.



Look at this simple table with calculated field :

http://i.imgur.com/SPqgPTz.png

The third field (called amount) is just the multiplication of unit price by quantity.


If you look at the result in the Tablegrid here is what you get :

http://i.imgur.com/HzeJxAD.png


The calculation is done correctly BUT... if you look at the database file, here is what you'll find :

http://i.imgur.com/RukfYUp.png


There is no trace of the calculated field. This is because the calculated value is not stored in the database, it is calculated each time you display the result in the Tablegrid.


You have 2 choices :

1- you setup a field in the database, which is not calculated but in which you store the value you have calculated yourself (I do not advise that because if you change the stored values for price and quantity, the calculation is not automatically updated)

2- you include the calculation in your query


This is valid for my example with prices and quantities, and this is also valid for your example with dates.


In your case, I guess that the part in red in 'SET  Duedate = DATE(Caldate,'+365 Day')' is querying a value that is not stored but calculated, so this red part should be a sub-query in your query recalculating the value.


Unfortunately, I do not have enough material to help you further without code and database.


Hope this helps a little


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor