Need to add months to date field . But month is not a fixed value

malaisamy1
Kilo Contributor

Hi Guys ,

I have scenario as below,

We have a "date field"(u_date) in "Table A". And we have "month field"(u_month)(number of months to be added field. Its a integer field) in "Table B"

So the query is

Table B fields 'slt_id' and 'ma_id' is matching with Table A fields 'serv_id' and 'cont_id'

Note: The Table A and Table B Fields are reference fields

then it has to add the number of months from 'Table B'   month field to date date field from table A and store the result in 'result_d' field.

Can someone help me to resolve this issue?

Thanks in advance.

1 ACCEPTED SOLUTION

larstange
Mega Sage

Hi



I'm not sure when you want to trigger the calculation (my guess is a business rule). The calculation is done with a glidedatatime object. Something like this



var month = [month field from table b];


var date = [date field from table a];



var gdt = new GlideDateTime(date);


gdt.addMonths(month);


date = gdt; //Update the date field on table a with this value


View solution in original post

1 REPLY 1

larstange
Mega Sage

Hi



I'm not sure when you want to trigger the calculation (my guess is a business rule). The calculation is done with a glidedatatime object. Something like this



var month = [month field from table b];


var date = [date field from table a];



var gdt = new GlideDateTime(date);


gdt.addMonths(month);


date = gdt; //Update the date field on table a with this value