Topic: Automatically increment a date field

Hello everyone
I would like to automatically increment the date of a 30-day date field in another Date field.
How do you do it?
Thank you

Re: Automatically increment a date field

With a sql script:

insert into table2 (column_month+1) values (select date("column_date", '+1 month') from table1 where id=id_number)

The destination table must match the type of the source regarding Date or Datetime.

You may have to tinker a bit with the date format

3 (edited by derek 2019-01-29 21:27:20)

Re: Automatically increment a date field

Hello Reteinformatica, Thierry
Another way to approach the problem:  in the attached example, the second date field is automatically set to be 30 days ahead of the first date field;  this is done with a small (1 line) script. 
Is this the sort of thing you were meaning?  Even if not, it shows one approach you could take.
Regards,
Derek.

Post's attachments

Attachment icon incrementdate.zip 336.88 kb, 355 downloads since 2019-01-29 

Re: Automatically increment a date field

Thanks to anwer,
sorry but I'm not an expert of languages code. Where I have to put that script?
Unfortunately I have using the last free version, it didn't open me your project derek.

Re: Automatically increment a date field

Which version are you using reteinformatica?

Nice and sweet Derek, I like your elegant solution!

6 (edited by reteinformatica 2019-01-29 23:42:43)

Re: Automatically increment a date field

I'm using 1.44, the last freeware

Re: Automatically increment a date field

The last free version was 1.46!!

8 (edited by reteinformatica 2019-01-29 23:32:36)

Re: Automatically increment a date field

I downloaded it from Database For Beginners Book inside link, in the help it's Witten 1.44

Re: Automatically increment a date field

Never mind, I have re-made Derek's example using the version 1.44

It is super easy to understand.

Post's attachments

Attachment icon Incremental 1.44.zip 323.01 kb, 318 downloads since 2019-01-30 

10 (edited by reteinformatica 2019-01-30 13:33:38)

Re: Automatically increment a date field

Hello everyone
And thank you for all the help you're giving me. I modified the script to adjust it to my project so

procedure frmFornitore_dtData_OnChange (Sender: TObject);
begin
  frmFornitore.dtScadenza.date := frmFornitore.dtData.date + 30;
end;

begin
end.

Unfortunately id does not work and I can not understand why.
If someone has patience I am attaching my project.
Thanks again to all

Post's attachments

Attachment icon SuperGulp.zip 328.47 kb, 326 downloads since 2019-01-30 

Re: Automatically increment a date field

When you implement a procedure in a script, you must affect that procedure to an event on an object.

Post's attachments

Attachment icon SuperGulp_fixed.zip 329.16 kb, 337 downloads since 2019-01-30 

12 (edited by tcoton 2019-01-30 16:22:53)

Re: Automatically increment a date field

Like this:http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=5009

Post's attachments

Attachment icon screenshot3.png 253.78 kb, 154 downloads since 2019-01-30 

13 (edited by reteinformatica 2019-01-30 17:38:43)

Re: Automatically increment a date field

Well, thank you very much, that was the passage I missed, thanks to Derek for the script and all those who responded. Now it works well.