I want importing data from Excell file in that file format of date are as follows :
Year-Month-Date ex: 2011-09-19,
I want to change it format like month/date/year
i tryed Date , month, year function for extracting individual day, year month but it's not working.
Thanks
Nishant
You'll need to import the value into an extra text field and convert the data using the Replace function to massage the data post-import.
Perform Replace Function:
GoodDate = middle ( TextDate ; 6 ; 2 ) & "/" & Right ( TextDate ; 2 ) & "/" & Left ( TextDate ; 4 )
Where GoodDate = a valid date field and TextDate = the field containing the imported data
I assume here Fechaseguimiento Contains date format:2011-09-19
Substitute ( Trim ( Substitute ( MiddleValues ( Substitute (Fechaseguimiento; "-" ; "¶") ; 2 ; 1) & MiddleValues ( Substitute (Fechaseguimiento ; "-" ; "¶") ; 3 ; 1) &LeftValues (Substitute (Fechaseguimiento; "-" ; "¶");1) ; "¶" ; " ") ); " " ;"/")
Related
I created an ExecuteSQL Calculation:
ExecuteSQL ( "SELECT BaseRent FROM obj_Unit_CurrentRenter_RentAmount WHERE RenterUnitID = ? AND CurRent = 1" ; "," ; ""; RenterUnitID)
I've verified that is works when I take out the AND CurRent = 1 clause. However, with that part in it, the calculation returns a ?.
CurRent is a Number field.
The problem is that your field name CurRent collides with the reserved word CURRENT.
Change your formula to:
ExecuteSQL ( "SELECT BaseRent FROM obj_Unit_CurrentRenter_RentAmount WHERE RenterUnitID = ? AND \"CurRent\" = 1" ; "," ; ""; RenterUnitID)
I want to calculate if a value falls outside of 10% of the last two values added to a database. This calculation is not giving me correct feedback when I have 'Weight" values close to 10, or from 100-110. Otherwise it works fine.
Case (
Get(RecordNumber) ≤ 2 ; "Continue Collecting Data" ;
(((GetNthRecord ( Weight ; Get(RecordNumber)-2))*.9) ≤ Weight) and
(((GetNthRecord ( Weight ; Get(RecordNumber)-2))*1.1) ≥ Weight) and
(((GetNthRecord ( Weight ; Get(RecordNumber)-1))*.9) ≤ Weight) and
(((GetNthRecord ( Weight ; Get(RecordNumber)-1))*1.1) ≥ Weight);
"Stable";
"Unstable")
I’m going to start with the assumption that your table includes fields for both the primary key and the creation timestamp. If not, I would highly recommend adding both to this table and every other table you create.
Assuming these fields are in place, you need to create another occurrence of the table on which this layout is based, then relate the primary key to itself via a Cartesian (×) join. Sort the relationship by creation timestamp descending. Your calculation is then:
Case (
(((GetNthRecord ( Weight ; 1 ) *.9 ) ≤ Weight) and
(((GetNthRecord ( Weight ; 1 ) *1.1 ) ≥ Weight) and
(((GetNthRecord ( Weight ; 2 ) *.9 ) ≤ Weight) and
(((GetNthRecord ( Weight ; 2 ) *1.1 ) ≥ Weight);
"Stable";
"Unstable")
Another thing I noticed is that your code is kind of complex. The Let function can make things easier to read, and your four criteria can be cut down to whether either difference is out of range. So, a simpler version becomes:
Let ( [
#weight1 = GetNthRecord ( all::weight ; 1 ) ;
#weight2 = GetNthRecord ( all::weight ; 2 )
] ; //end define Let
Case (
Abs ( #weight1 - weight ) > .1 ; "Unstable" ;
Abs ( #weight2 - weight ) > .1 ; "Unstable" ;
"Stable"
) //end Case
) //end Let
Does that help?
Assuming you are using FileMaker v12 or later, this looks like a good place to use the ExecuteSQL function (not the script step) to retrieve the last two values. You could do something like this:
Let (
sqlQuery = "
SELECT t.weight
FROM MyTable t
WHERE t.id <> ?
ORDER BY t.id DESC
FETCH FIRST 2 ROWS ONLY
" ;
ExecuteSQL ( sqlQuery ; "" ; "" ; MyTable::id )
)
This query assumes you have a unique 'id' field (i.e. a primary key) that's defined as an 'auto-enter serial' value. The WHERE clause makes sure that the current record (presumably the one the user is entering) is not included in the query. The ORDER BY DESC clause forces the last two records to the top where we can fetch the 'weight' values easily into a value list.
Assuming you use a 'Set Variable' script step to put the query results into $lastValues, you can then test for whether they are in range like so:
Let ( [
lastValue1 = GetValue ( $lastValues ; 1 ) ;
lastValue2 = GetValue ( $lastValues ; 2 ) ;
Value1_InRange = lastValue1 - Abs ( lastValue1 - weight ) >= ( 0.9 * lastValue1 ) ;
Value2_InRange = lastValue2 - Abs ( lastValue2 - weight ) >= ( 0.9 * lastValue2 )
] ;
Value1_InRange and Value2_InRange // returns 1 if both values within range, 0 if not
)
If I were doing this, I would put the above range-checking code into a custom function so it's generic and can be easily reused:
IsWithinRange ( valueToTest ; lastValue ; range ) =
lastValue - Abs ( lastValue - valueToTest ) >= ( ( 1 - range ) * lastValue )
Then the above range-checking code can be reduced to:
IsWithinRange ( MyTable::weight ; GetValue ( $lastValues ; 1 ) ; 0.1 ) &
IsWithinRange ( MyTable::weight ; GetValue ( $lastValues ; 2 ) ; 0.1 )
And one last note.. if you use the ExecuteSQL function in a calculated field, be sure to make it 'unstored' so that it only executes when needed. However, I would recommend you avoid that altogether and simply call it from a script step like 'Set Variable'. That way you can control exactly when it executes.
Hope that helps!
I've a string like 'intercompany creditors {DEMO[[1]]}'. I want to extract only the numbers from the string, in example just '1'.
How to do this in Invantive SQL?
You should be able to do so with substr (get some piece of text from specific positions in the text) and instr (get the position from a specific piece of text inside some other text):
select substr
( d
, instr(d, '[[') + 2
, instr(d, ']]') - instr(d, '[[') - 2
)
from ( select 'intercompany creditors {DEMO[[1]]}' d
from dual#DataDictionary
) x
FMP12
I need to use commas to separate data from customer addresses. The address is imported into a notes field like this: "1234 East Palm Ave, Berkeley, Ca 94150".
My script needs to recognize if the street name is 2 or 3 words, and if the city name is 1 or 2 words. The info gets broken up into a couple different Set Variables $streetName, $CityName, $ZipCode, and exported to create a new customer profile.
I was trying to do that with a string search function that finds the position of the first and second instand of each "," but my function isn't working. Any hints about which function to use would be greatly appreciated.
Assuming the formatting is consistent, try:
$streetName =
Let (
tokens = Substitute ( Address ; ", " ; ¶ )
;
GetValue ( tokens ; 1 )
)
$cityName =
Let (
tokens = Substitute ( Address ; ", " ; ¶ )
;
GetValue ( tokens ; 2 )
)
$zipCode =
RightWords ( Address ; 1 )
I have a function that takes in the personalia of a person
function person = prompt_person ()
name = input ( ' Whats your name ? ' , 's' ) ;
day = input ( ' What day of the month were you born ? ') ;
month = input (' What month were you born ? ') ;
year = input ( ' What year were you born? ') ;
phone = input ( ' Whats your telephone number ? ') ;
date_of_birth = struct ('day', day, 'month', month, 'year', year) ;
person = struct ( 'name' , name, 'date_of_birth' , date_of_birth , 'phone' , phone ) ;
end
But I keep getting the error message "Invalid field name "name" ", "Error message in prompt_person (line 8) And I have no idea whats wrong because I've tried creating a simpler little test function:
function [out] = tes( )
word=input('Insert word here ','s');
num=input('Insert number here ');
out= struct('Number1', word, 'Number2', num);
end
And it works just fine, even though it seems to be the exact same code which gets me in toruble in the first function. Any ideas what's going on here?
I tried changing the variable name to personName as suggested and I accidentaly found out whats wrong:
Turn out I needed to use a variable name with no space between the '' and the text.
E.g. 'PersonName' instead of ' PersonName '.
You might consider using strtrim to strip leading and trailing whitespeace from a string. For example:
>> name = ' John Doe ';
>> name = strtrim(name)
name =
John Doe
If you need to remove all spaces, try strrep(name,' ','').
>> name = strrep(name,' ','')
name =
JohnDoe