I have table employees with the following fields.
emp_id (int)
emp_name (varchar)
posting_date (datetime)
serviceinyear (datetime)
I want on the view page the service of the employees should be displayed. the field "serviceinyear" should display the number of months of service. What custom code should I write in the "view as setting custom code" for "serviceinyear" that calculate the service in months to displayed on the view page.
I used this code. But when i use if condition it gives error. How i should use if condition
strValue=data("Smonth")
posting=data("Posting_Date")
monthDob=DatePart("m",posting)
MonthNow=DatePart("m",date())
if (MonthNow>=monthDob)
monthAge= MonthNow-monthDob;
else
{
var monthAge= 12+MonthNow-monthDob;
}
strValue=monthAge
When i run this code. the if condition gives an error. how should I use the if/else condition to calculate the exact months of age