Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with ExecuteSQL Script Step, Date Range

Featured Replies

Hi,

 

I'm having trouble using the WHERE command to allow a User to dynamically select a date range. The process works well for a single date. But not when I try to establish a date start & date end. The scripts are below. The first one works, second doesn't. Any help would be greatly appreciated!

 

(Note: there is one additional script that kind of "kick starts" the main script. It contains an optional script parameter: INVOICE::virtual_salesboard_date_start)

 

 

 

(first line in the script is Set Variable [$date;Value:Get(ScriptParameter)

// ------------  BEGIN EXECUTESQL BLOCK ------------  

Let ( [

ReturnSub = "n" ; // We need to swap out carriage returns in your results with a different character, so specify the character here.  n is the default.
SQLResult = ExecuteSQL (

// ------------  BEGIN QUERY ------------

"SELECT a."Invoice By NEW", COUNT (DISTINCT a."virtual_salesboard_order_count"), SUM(a."virtual_salesboard_totalSold"), SUM(a."virtual_salesboard_totalSold_color")
FROM "VSB_DATA" a
WHERE a."Invoice Date"= ?
GROUP BY a."Invoice By NEW"
" ;

// ------------  END QUERY ------ ------

// ------------  BEGIN FIELD AND ROW SEPARATORS ------------

"|" ; "|*|" ;

// ------------  END FIELD AND ROW SEPARATORS ------------

// ------------  BEGIN ARGUMENTS ------------  
// ------------  These arguments are pulled from the values you entered when running your query.  You can substitute your own values, fields or variables here. One argument per ? in your query, in query order, separated with semicolons. ------------

$date

// ------------  END ARGUMENTS ------------  

 ) ] ;

// ------------  BEGIN CARRIAGE RETURN SUBSTITUTIONS ------------  

 Substitute ( SQLResult ; [ ¶ ; ReturnSub ] ; [ "|*|" ; ¶ ]  )

// ------------  END CARRIAGE RETURN SUBSTITUTIONS ------------  

)

// Compliments of SeedCode… Cheers!

// ------------  END EXECUTESQL BLOCK ------------

 

 

 

#2

 

there are two Set variable steps at the beginning:

Set Variable[$date1;Value:Invoice::virtual_salesboard_date_start]

Set Variable[$date1;Value:Invoice::virtual_salesboard_date_end]

// ------------  BEGIN EXECUTESQL BLOCK ------------  

Let ( [

ReturnSub = "n" ; // We need to swap out carriage returns in your results with a different character, so specify the character here.  n is the default.
SQLResult = ExecuteSQL (

// ------------  BEGIN QUERY ------------

"SELECT a."Invoice By NEW", COUNT (DISTINCT a."virtual_salesboard_order_count"), SUM(a."virtual_salesboard_totalSold"), SUM(a."virtual_salesboard_totalSold_color")
FROM "VSB_DATA" a
WHERE a."Invoice Date"  BETWEEN ? AND ?
GROUP BY a."Invoice By NEW"
" ;

// ------------  END QUERY ------ ------

// ------------  BEGIN FIELD AND ROW SEPARATORS ------------

"|" ; "|*|" ;

// ------------  END FIELD AND ROW SEPARATORS ------------

// ------------  BEGIN ARGUMENTS ------------  
// ------------  These arguments are pulled from the values you entered when running your query.  You can substitute your own values, fields or variables here. One argument per ? in your query, in query order, separated with semicolons. ------------

$date1;$date2

// ------------  END ARGUMENTS ------------  

 ) ] ;

// ------------  BEGIN CARRIAGE RETURN SUBSTITUTIONS ------------  

 Substitute ( SQLResult ; [ ¶ ; ReturnSub ] ; [ "|*|" ; ¶ ]  )

// ------------  END CARRIAGE RETURN SUBSTITUTIONS ------------  

)

// Compliments of SeedCode… Cheers!

// ------------  END EXECUTESQL BLOCK ------------

Hi I see you are using the SQL Explorer does this work when you run the query in the tool?

Set Variable[$date1;Value:Invoice::virtual_salesboard_date_start]

Set Variable[$date1;Value:Invoice::virtual_salesboard_date_end]

 

Looks like you are setting $date1 twice.

Shouldn't that be:

 

Set Variable[$date1;Value:Invoice::virtual_salesboard_date_start]

Set Variable[$date2;Value:Invoice::virtual_salesboard_date_end]

In addition to what BruceR said, I would change:

 

 BETWEEN ? AND ? to

 

a."Invoice Date" <= ? AND a."Invoice Date" >= ?

 

Hope this helps

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.