# Need help with dates in RecordQuery (MBS)

**URL:** <https://the.fmsoup.org/t/need-help-with-dates-in-recordquery-mbs/354>\
**Category:** MBS Plugins\
**Created:** [October 2, 2019, 12:30pm UTC](https://the.fmsoup.org/t/need-help-with-dates-in-recordquery-mbs/354 "2019-10-02T12:30:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wibenji](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/wibenji/32/241_2.png) [@wibenji](https://the.fmsoup.org/u/wibenji)\
**Post date:** [October 2, 2019, 12:30pm UTC](https://the.fmsoup.org/t/need-help-with-dates-in-recordquery-mbs/354/1 "2019-10-02T12:30:30Z")

</div>

I hope this is the right place to ask this question. If not just delete this post.  
I´m using the "FM.InsertRecordQuery" function from the MBS-Plugin to fetch some data from 1 Filemaker-Table to another one.  
This is the query  
`"SELECT \"pr_gruppe\",\"artnr\",\"aname\",\"aname2\",\"einheit\",\"hkl\",\"herkunft\",\"leergut\",\"gr_nr\",\"inhalt\",\"per\",\"preis_ko\",\"preis_me\",\"preis_anbr\",\"tagespreis\",\"hat_info\","&$$param_kdnr&" as \"bkdnr\" FROM SHOPPRL where \"pr_gruppe\"="&$$param_prgrupp&" AND "&$$param_date&" >= gueltig_von AND "&$$param_date&" <= gueltig_bis"`  
It does work if i omit the last part with $$param\_date. Otherwise i get this error:  
`[MBS] ERROR: FQL0001/(1:218): There is an error in the syntax of the query.`  
I have tried changing several things but i cant figure out what to do.  
What i try to do is selecting records that have a valid price. It is valid if $$param\_date is BETWEEN gueltig\_von and gueltig\_bis. They are in date-format. (dd.mm.yyyy).

Any help would be greatly appreciated

Wibenji

---

<div class="post-metadata">

**Author:** ![Markus](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Markus](https://the.fmsoup.org/u/Markus)\
**Post date:** [October 2, 2019, 2:07pm UTC](https://the.fmsoup.org/t/need-help-with-dates-in-recordquery-mbs/354/2 "2019-10-02T14:07:58Z")

</div>

not sure, if $$Vars are working in the ‘select’

as for parameters: Why not use the filemaker executeSQL function with parameters? There, the conversion of dates might be easier.  
(MBS sql also allows external parameters)

executeSQL  
(  
“SELECT field1, field2, field3 FROM TheTable WHERE xx=? AND yy=?”;  
“”;  
“”;  
myTO::thisField; myOtherTO::thatField  
)

---

<div class="post-metadata">

**Author:** ![wibenji](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/wibenji/32/241_2.png) [@wibenji](https://the.fmsoup.org/u/wibenji)\
**Post date:** [October 2, 2019, 2:21pm UTC](https://the.fmsoup.org/t/need-help-with-dates-in-recordquery-mbs/354/3 "2019-10-02T14:21:36Z")

</div>

Thank you so much Markus. External Parameters solved my problem. Somehow the $$Vars don´t work when they are dates. I have put them into the external parameters now and it works fine. You saved my day

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [April 15, 2020, 9:21pm UTC](https://the.fmsoup.org/t/need-help-with-dates-in-recordquery-mbs/354/4 "2020-04-15T21:21:10Z")

</div>

Using external parameters solves many problems.

I have seen this form fail:

```
executeSQL( “SELECT field FROM table WHERE x=” & $VAR ;“”;“” )

```

while this form is successful:

```
executeSQL( “SELECT field FROM table WHERE x=?” ;“”;“”; $VAR )
```

---

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [April 15, 2020, 9:33pm UTC](https://the.fmsoup.org/t/need-help-with-dates-in-recordquery-mbs/354/5 "2020-04-15T21:33:59Z")

</div>

With [FM.InsertRecordQuery](https://www.mbsplugins.eu/FMInsertRecordQuery.shtml), you can also use parameters there.

e.g.  
MBS( "[FM.InsertRecordQuery](https://www.mbsplugins.eu/FMInsertRecordQuery.shtml)"; ""; "Test"; "FirstName¶LastName¶CompanyName"; ""; "SELECT "First", "Last", "Company" FROM Contacts WHERE City=?"; "Hamburg" )

---

<div class="post-metadata">

**Author:** ![wibenji](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/wibenji/32/241_2.png) [@wibenji](https://the.fmsoup.org/u/wibenji)\
**Post date:** [April 16, 2020, 6:21am UTC](https://the.fmsoup.org/t/need-help-with-dates-in-recordquery-mbs/354/6 "2020-04-16T06:21:29Z")

</div>

That is actually what i´m using now Christian.
