Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can you use a date variable in Edit Script?

Hi

I am trying to limit the number of records that I import in Edit Script by using a date variable.

One table has one record with a date field which I want to use as the variable . The other table has the records.

Table with date record:

LOAD date,

    Module;

SQL SELECT *

FROM live where Module = 'db';

The code with the variable is below:

LOAD

    date,

    debtor,

    amt;

SQL SELECT

      date,

      debtor,

      amt

From debtor_table where date >= 'variable';

Is it possible to link the variable to a value that is retrieved in earlier script from a different table?

I notice that there are some system variable names for dates - can I use them as the variable instead?

Regards

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Yes, something like this for example. You will need to make sure that the variable gets the same date format as the date field in your second table has.

T1:

LOAD date,

    Module;

SQL SELECT *

FROM live where Module = 'db';

LET vDate = peek('date');           //pick the date value from the last record of table T1

T2:

LOAD

    date,

    debtor,

    amt;

SQL SELECT

      date,

      debtor,

      amt

From debtor_table where date >= '$(vDate)';


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
khadeer
Specialist
Specialist

Instead of that u can change both fields as same date format(i.e 'YYYY-MM-DD') then keep as same name to both fields then give the association.

Gysbert_Wassenaar

Yes, something like this for example. You will need to make sure that the variable gets the same date format as the date field in your second table has.

T1:

LOAD date,

    Module;

SQL SELECT *

FROM live where Module = 'db';

LET vDate = peek('date');           //pick the date value from the last record of table T1

T2:

LOAD

    date,

    debtor,

    amt;

SQL SELECT

      date,

      debtor,

      amt

From debtor_table where date >= '$(vDate)';


talk is cheap, supply exceeds demand
Not applicable
Author

Hi,

Perhaps, you can try something like this:

TableWithDateRecord:

Load * Inline

[

DateField

1/4/2013

];

Let datevariable=('DateField',-1,'TableWithDateRecord');

OtherTable:

Load * Inline

[

Key,Value,Date

A,10,1/3/2012

B,20,1/2/2013

C,30,1/12/2013

D,40,1/4/2013

E,40,2/4/2013

]

;

Load *

Resident OtherTable

where Date <$(datevariable);

Regards,

-Khaled

Not applicable
Author

Thanks Gysbert

I have used coding in Access before but QV is different.