Topic: Calculated field help

I'm trying to calculate how many days left for a task needs to be completed.

I have task start date and task end date.

From end date and current day, I like to calculate and display days left to finish the task.

Adam
God... please help me become the person my dog thinks I am.

2 (edited by joshuA 2021-09-19 19:36:55)

Re: Calculated field help

Hi AD1408,
.
This has worked for me in the past:
.

Form1.tbDaysBetween.Text := IntToStr(DaysBetween(Form1.beginDate.DateTime , Form1.endDate.DateTime));

.
In this example the beginDate and endDate are both DateTimePickers.
.
Also refer to: http://www.delphibasics.co.uk/RTL.asp?Name=DaysBetween

"Energy and persistence conquer all things."

Re: Calculated field help

Hi Jashua,


Thanks a lot for the reply.
I need to display days left to finish the task, updating the days every day using current date, start and end date. Not just the days between two date.

Adam
God... please help me become the person my dog thinks I am.

Re: Calculated field help

Hi Adam,
Try it something like this (see attached).
You may need to juggle the calculation - some people like to include the startdate and/or enddate, others like to exclude it.
Derek.

Post's attachments

Attachment icon template.zip 336.44 kb, 194 downloads since 2021-09-20 

Re: Calculated field help

Hi Derek,


You have done more than what I asked for.
Thank you very much... It's great stuff and truly appreciated....


I wanted to display calc fields values in textboxes beside grid but couldn't get it working?

Post's attachments

Attachment icon DaysLeftToFinish_TASK_WORK.zip 5.99 kb, 188 downloads since 2021-09-20 

Adam
God... please help me become the person my dog thinks I am.

Re: Calculated field help

Adam,
Keep in mind that calculated fields are not real fields in the database. It is basically sql code to calculate and produce a single value utilizing other fields from the database. They are only available during the running of the program and are primarily used in tablegrids and basic reports. If you want to utilize them in other ways such as you are doing with text fields, then you need to replicate the sql of your calculated field into your script. See attached.

Post's attachments

Attachment icon DaysLeftToFinish_TASK_WORK Corrected.zip 338.39 kb, 201 downloads since 2021-09-20 

Re: Calculated field help

Hi EHW,

I thought it needed something like that but I couldn't work out the sql script.


Thank you very much.... Truly appreciated...

Adam
God... please help me become the person my dog thinks I am.