forked from NYHTC/fm-functions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQL_DateToFM.xml
32 lines (25 loc) · 899 Bytes
/
SQL_DateToFM.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<fmxmlsnippet type="FMObjectList">
<CustomFunction id="50" functionArity="1" visible="True" parameters="sqlDate" name="SQL_DateToFM">
<Calculation><![CDATA[// SQL_DateToFM ( sqlDate )
// version 1.1.1, Daniel A. Shockley, NYHTC
/*
Convert SQL date to FileMaker date.
HISTORY:
1.1.1 - 2016-09-29 ( eshagdar ): updated documentation.
1.1 - 201x-xx-xx ( xxxxx ): Returns an empty date when the SQL date is an empty string, instead of a "?"
1.0 - 201x-xx-xx ( dshockley ): first created.
*/
Let ( [
sqlDate =
If ( LeftWords ( sqlDate; 1 ) ≠ "DATE"
; sqlDate
; RightWords ( sqlDate; WordCount ( sqlDate ) - 1 )
)
; sqlDate = Substitute( sqlDate; "-"; "¶" )
; fmDate = If ( IsEmpty ( sqlDate ); GetAsDate ( "" ); Date ( GetValue ( sqlDate; 2 ); GetValue ( sqlDate; 3 ); GetValue ( sqlDate; 1 ) ) )
];
fmDate
)]]>
</Calculation>
</CustomFunction>
</fmxmlsnippet>