How I can I convert number of months into year?
Discussion posts and replies are publicly visible
Divide by 12?
You need to give us more to go on. For this it would be good to have expected inputs and outputs. Is this what you're after?
Input 12 --> Output 1
Input 36 --> Output 3
Input 18 --> Output 1.5
Input 25 --> Output 2.08
Do you mean how do I convert, for example 18 months into 1.5 years? or 9 months into 0.75 years? If so, that's a pretty straightforward calculation - divide your number by 12 and, perhaps, express the value to 2 decimals points.
If that's not what you meant perhaps you can elaborate on your requirement?
a!localVariables( local!months, local!year, { a!textField( label: "Enter month", value: local!months, saveInto: local!months ), a!textField( label: "Year (s)", value: if( or(isnull(local!months)), "", quotient(local!months,12) & " year and " & mod(local!months,12) & " month", ), saveInto: local!year ) } )
Please try this code
this is fine ,but now I have the sp rule in which it is returning no of months fox ex: 6 months. i need to use this 6 or 12 or 24 months with the date and convert into months , how will i do that?
yes I have the sp rule in which it is returning me no of months in terms of days(for ex: 6 months or 12 months in 6 or 12),I need to convert that days (6 days into months) with the date, how i can do this? I need do use sp output only.
I'm still struggling to understand what you need. Does the stored procedure ONLY return 6 months? Does it return 6 months and a date and you want to add the 6 months to the date and end up with another date? We have no idea what you need.
Now you're introducing "days" into the discussion and you have lost me...I don't understand what you're trying to achieve. Can you provide more detail please.
okay sure. yes I have sp rule which is taking inputs as integer values and giving me output as a integer. so now i am trying to convert those days(6 or 12 or 24 etc) into months and add to date(date may be dd/mm/yy) my code is below
/* this is sp rule*/ a!localVariables( local!spResult: fn!executestoredprocedure( dataSourceName: cons!DATASOURCE_NAME, procedureName: cons!SP_MONTHS, inputs: { { name: "CI", value: ri!ci_int, }, { name: "CODE", value: Code_int, } } ), if( and( local!spResult.success, not( isnull( local!spResult.parameters ) ) ), local!spResult.parameters.MONTHS, "" ) )
Am I providing detail?
We still can't understand what you're trying to actually accomplish. Maybe give an example of the end result you'd expect given a particular stored procedure result (or 2 such examples)?