AnsweredAssumed Answered

Calculation-> date doesn't work.

Question asked by ultranix on Jan 12, 2011
Latest reply on Jan 12, 2011 by philmodjunk


Calculation-> date doesn't work.



I have a personal code in one field, which contains date of birth information: year, month, and day. And I have another field: date of birth. I tried to add "Auto-enter->Calculated value" to date of birth field, so whenever i specify personal code, it would automatically enter date of birth. For no particular reason, it just doesn't work and all i see in browse mode after creating new record and entering personal code is question mark. Strangely enough, when I view data in data viewer, it returns just the way it should be. Maybe it's because DOB field is set to "DATE" type? But I want it to be set to date, because i want to use drop down calendar other times when personal code is not available.

Here's a formula i put in calculation:

Let ( [
data = Sales::Persicode; // field i am using
Y1 = Middle (data;1;1); // first character of persicode and it determines the century (1-2: 18XX; 3-4: 19XX; 5-6: 20XX)
y = Case (Y1 > 4; "20"; Case (Y1 >2; "19"; Case (Y1 >0; "18"))) & Middle (data;2;2); // year calculation
m = Middle (data;4;2); // month
d = Middle (data;6;2); // day
] ;
y & "-" & m & "-" & d