Hi ; you have me somewhat confused ; you talk about 'SQL Management Studio' which implies you are on a SQL Server database, yet you then use NVL which is an Oracle function? Which database are you on?
Some comments that might help you though...
"DATEDIFF" is a SQL Server function, Oracle has different functions ; e.g. "MONTHS_BETWEEN" will just give you a decimal number for the difference between two dates.
I think you are getting errors in the application just because you have "assumed" a standard date format for your date - you have used the default Oracle date format (which is why it "works" in your SQL tool but the application will not necessarily use the same date format. If your logic really needs to cast a string to a date then you should always include the format in that cast to get around this. In Oracle you would just need to use to_date with an explicit format mask ( e.g. to_date('01-JAN-89','DD-MON-YY') ) in SQL Server you use CONVERT with format type 106 (I think)
Not sure why you say there is no ISNULL() function - in SQL Server there is, in Oracle it is just NVL(). If you want to make NSQL code agnostic to the database use @NVL@ and that takes care of either.
You can do the "date difference in months" in a number of ways depending on your required logic - the way you have it at the moment is OK, but as you realise it is the number of days between two dates divided by 30.
As mentioned above there is an Oracle function to return a decimal number for the number of months between two dates though ; unsurprisingly it is the MONTHS_BETWEEN function - could just use that and round the answer as you need to?
But you could want to say the difference between the "month of date 1" and the "month of date 2"
(so convert each date to a month value using TRUNC (in Oracle) ; trunc ( mydate , 'MONTH') will return the date of the first day in a month, then use MONTHS_BETWEEN on the results).
Look here for some comparison of DATEDIFF and MONTHS_BETWEEN ; MONTHS_BETWEEN Function - Oracle to SQL Server Migration - SQLines Open Source Tools ( since I still am not sure what DB you are on! )