Skip to content

Instantly share code, notes, and snippets.

@IronistM
Created November 11, 2013 10:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IronistM/7411253 to your computer and use it in GitHub Desktop.
Save IronistM/7411253 to your computer and use it in GitHub Desktop.
This code sets variables to define a time period (previous calendar month) dynamically changing the SQL statement sent to source
let vLastMonth = Year(AddMonths(now(),-1)) & '-' & num(month(addmonths(now(),-1)),'00') & '-01';
// This gets the first of the previous month
let vThisMonth = Year(now()) & '-' & num(month(now()),'00') & '-01';
// This gets the first of the current month
ODBC CONNECT TO MyDSN; // Change to your database
LOAD *;
SQL SELECT
DATE,
NAME,
CODE
FROM MyTable
WHERE DATE >= '$(vLastMonth)' AND
DATE < '$(vThisMonth)';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment