This topic is locked

Date Difference Auto-Complete

1/23/2006 4:10:39 PM
PHPRunner General questions
prleo1 author

Admin,
I have a child table that relates to Personnel named R&R.

The table is as such:
leave_type: VARCHAR

leave_date: DATE

Back_2_work_date: DATE

rr_duration: back_2_work_date - leave_date = rr_duration
I am trying to use the lookup wizard to retrieve the total days of the user going on vacation. His vacation duration would be calculated by back_2_work_date - leave_date = rr_duration.
I put the following in the Lookup Wizard's default value for rr_duration:

CONCAT(datediff("back_2_work_date", "leave_date"),' ', "Days")
Now, I am getting a nice error when trying to run the page. What am I doing wrong?

admin 1/24/2006

Hi,
it seems that you should use Display field - Custom expression instead of Default valuefor Lookup wizard.
Anyway, this is not a valid MySQL expression.

Here is the correct one:

CONCAT(datediff(back_2_work_date, leave_date),' ', "Days")
prleo1 author 1/24/2006

Admin,

I tried that as well and get the error...
Parse error: syntax error, unexpected T_STRING in E:\app\web\wwwroot\***\include\v3_personnel_rr_functions.php on line 659
duration (read_only) = CONCAT(datediff(rr_start_date, end_of_rr),' ',"days"
I am trying to auto-fill the duration field with the date difference of the two fields above.

admin 1/24/2006

You miss closing parenthesis at the end.

prleo1 author 1/24/2006

You miss closing parenthesis at the end.


So, I put the code in the Custom Expression field and noticed that this is enabling a drop-down of all the values that are in the RR Table/View. I am trying to auto-calculate/auto-insert the value of the RR duration, in days, by using the datediff function on the end_date and start_date fields.