In Marketing Cloud -> Automation Studio -> Script Activity, I am trying to run a script that updates a column named "age" (dtype: integer) based on another column named "date of birth" (dtype: date). It is within a single data extension named "User".
The idea is to loop/iterate through all the subscribers/records, calculate the age of the given subscriber based on the column "date of birth" and then update the column "age" with the respective age. Thus, I want the update the column "age" based on a calculation on another column, "date of birth" (calculation is in the var "aged" within the code snippet). The primary key of the data extension is the SubscriberKey.
I have put together the following code, however it does not work and I feel I am missing something (I am totally new to SSJS).
<script runat="server">
Platform.Load('core', '1');
var testDE = DataExtension.Init("User");
var testDEData = testDE.Rows.Retrieve();
for (var i = 0; i < testDEData.length; i++) {
var subKey = testDEData[i].SubscriberKey;
var dob = testDEData[i]."date of birth";
var aged = testDE.FLOOR((TODAY() - "date of birth"__c)/365.2425);
var processing = testDE.Rows.Update({age:aged}, ["SubscriberKey"], [subKey]);
}
</script>
Do you have any suggestions? Highly appreciated! Please tell me if you need further information.