Sorry! Parameter query / Again

D

D

Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

Dan


PARAMETERS [Rpt_Date] DateTime;
SELECT Table1.P_SUBTP, Table1.BOOK, Table1.SOURCE_GL, Table1.HEDGE_TP,
Table1.POS, Table1.POS_SUBCAT, Table1.TAX_CLS, Table1.RE_PL, Table1.PTFOLIO,
Table1.DEALNO, Table1.USD, Table1.GBP, Table1.EUR, Table1.HKD, Table1.JPY,
Table1.SGD, Table1.CHF, Table1.AUD, Table1.ILS, Table1.CAD, Table1.ACTIVE_CD,
Table1.DEAL_TP, Table1.INSTR_TP, Table1.TRANS_TP, Table1.BOA, Table1.ORG,
Table1.GL_ACCT, Table1.S_ACCT, Table1.PRODUCT, Table1.COUNTR_NO,
Table1.COUNTR_NM, Table1.TRADE_DATE, Table1.START_DATE,
Table1.LT_MATURITY_DATE, Table1.MATURITY_DATE
FROM Table1
WHERE (((Table1.TRADE_DATE)<=[Rpt_Date]) AND
((Table1.MATURITY_DATE)>[Rpt_Date]));
 
J

Jeff Boyce

"How" is based on how your data is structured.

Post a description of the data structure you are using.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

KARL DEWEY

This assumes that Table1.TRADE_DATE and [Table1].[MATURITY_DATE] are DateTime
datatype.

WHERE Format([Table1].[TRADE_DATE],"yyyymm")<=[Rpt_Date] AND
Format([Table1].[MATURITY_DATE],"yyyymm")>[Rpt_Date];
 
D

D

Hi Jeff:

Both dates are date/time data type; i.e. 06/13/2008.

Thanks,

Dan

Jeff Boyce said:
"How" is based on how your data is structured.

Post a description of the data structure you are using.

Regards

Jeff Boyce
Microsoft Office/Access MVP

D said:
Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do
that???

Thanks a lot!

Dan


PARAMETERS [Rpt_Date] DateTime;
SELECT Table1.P_SUBTP, Table1.BOOK, Table1.SOURCE_GL, Table1.HEDGE_TP,
Table1.POS, Table1.POS_SUBCAT, Table1.TAX_CLS, Table1.RE_PL,
Table1.PTFOLIO,
Table1.DEALNO, Table1.USD, Table1.GBP, Table1.EUR, Table1.HKD, Table1.JPY,
Table1.SGD, Table1.CHF, Table1.AUD, Table1.ILS, Table1.CAD,
Table1.ACTIVE_CD,
Table1.DEAL_TP, Table1.INSTR_TP, Table1.TRANS_TP, Table1.BOA, Table1.ORG,
Table1.GL_ACCT, Table1.S_ACCT, Table1.PRODUCT, Table1.COUNTR_NO,
Table1.COUNTR_NM, Table1.TRADE_DATE, Table1.START_DATE,
Table1.LT_MATURITY_DATE, Table1.MATURITY_DATE
FROM Table1
WHERE (((Table1.TRADE_DATE)<=[Rpt_Date]) AND
((Table1.MATURITY_DATE)>[Rpt_Date]));
 
D

D

Hi Karl:

Thank you!

Yes, trade date and maturity date are date/time data type; I have used your
criteria but I do not get the expected result; does not matter if I enter
200806 or 200806013 the result is the same??

Thanks again,

Dan

KARL DEWEY said:
This assumes that Table1.TRADE_DATE and [Table1].[MATURITY_DATE] are DateTime
datatype.

WHERE Format([Table1].[TRADE_DATE],"yyyymm")<=[Rpt_Date] AND
Format([Table1].[MATURITY_DATE],"yyyymm")>[Rpt_Date];

--
KARL DEWEY
Build a little - Test a little


D said:
Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

Dan


PARAMETERS [Rpt_Date] DateTime;
SELECT Table1.P_SUBTP, Table1.BOOK, Table1.SOURCE_GL, Table1.HEDGE_TP,
Table1.POS, Table1.POS_SUBCAT, Table1.TAX_CLS, Table1.RE_PL, Table1.PTFOLIO,
Table1.DEALNO, Table1.USD, Table1.GBP, Table1.EUR, Table1.HKD, Table1.JPY,
Table1.SGD, Table1.CHF, Table1.AUD, Table1.ILS, Table1.CAD, Table1.ACTIVE_CD,
Table1.DEAL_TP, Table1.INSTR_TP, Table1.TRANS_TP, Table1.BOA, Table1.ORG,
Table1.GL_ACCT, Table1.S_ACCT, Table1.PRODUCT, Table1.COUNTR_NO,
Table1.COUNTR_NM, Table1.TRADE_DATE, Table1.START_DATE,
Table1.LT_MATURITY_DATE, Table1.MATURITY_DATE
FROM Table1
WHERE (((Table1.TRADE_DATE)<=[Rpt_Date]) AND
((Table1.MATURITY_DATE)>[Rpt_Date]));
 
K

KARL DEWEY

I do not get the expected result
What do you get?

Post some sample data and example of results along with what you expect.

--
KARL DEWEY
Build a little - Test a little


D said:
Hi Karl:

Thank you!

Yes, trade date and maturity date are date/time data type; I have used your
criteria but I do not get the expected result; does not matter if I enter
200806 or 200806013 the result is the same??

Thanks again,

Dan

KARL DEWEY said:
This assumes that Table1.TRADE_DATE and [Table1].[MATURITY_DATE] are DateTime
datatype.

WHERE Format([Table1].[TRADE_DATE],"yyyymm")<=[Rpt_Date] AND
Format([Table1].[MATURITY_DATE],"yyyymm")>[Rpt_Date];

--
KARL DEWEY
Build a little - Test a little


D said:
Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

Dan


PARAMETERS [Rpt_Date] DateTime;
SELECT Table1.P_SUBTP, Table1.BOOK, Table1.SOURCE_GL, Table1.HEDGE_TP,
Table1.POS, Table1.POS_SUBCAT, Table1.TAX_CLS, Table1.RE_PL, Table1.PTFOLIO,
Table1.DEALNO, Table1.USD, Table1.GBP, Table1.EUR, Table1.HKD, Table1.JPY,
Table1.SGD, Table1.CHF, Table1.AUD, Table1.ILS, Table1.CAD, Table1.ACTIVE_CD,
Table1.DEAL_TP, Table1.INSTR_TP, Table1.TRANS_TP, Table1.BOA, Table1.ORG,
Table1.GL_ACCT, Table1.S_ACCT, Table1.PRODUCT, Table1.COUNTR_NO,
Table1.COUNTR_NM, Table1.TRADE_DATE, Table1.START_DATE,
Table1.LT_MATURITY_DATE, Table1.MATURITY_DATE
FROM Table1
WHERE (((Table1.TRADE_DATE)<=[Rpt_Date]) AND
((Table1.MATURITY_DATE)>[Rpt_Date]));
 
D

D

Hi Karl:

Please see the qry and table; now I get an error?

Thank you,

Dan

PARAMETERS [Rpt_Date] DateTime;
SELECT table1.ID, table1.Amt, table1.trade_date, table1.maturity_date
FROM table1
WHERE (((Format([Table1].[TRADE_DATE],"yyyymm"))<=[Rpt_Date]) AND
((Format([Table1].[MATURITY_DATE],"yyyymm"))>[Rpt_Date]));
***
ID Amt trade_date maturity_date
1 100 5/4/2008 12/13/2008
2 300 5/9/2008 10/6/2008
3 400 5/7/2008 9/8/2008
4 80 5/6/2008 8/7/2008
5 5 5/6/2008 7/6/2008

KARL DEWEY said:
What do you get?

Post some sample data and example of results along with what you expect.

--
KARL DEWEY
Build a little - Test a little


D said:
Hi Karl:

Thank you!

Yes, trade date and maturity date are date/time data type; I have used your
criteria but I do not get the expected result; does not matter if I enter
200806 or 200806013 the result is the same??

Thanks again,

Dan

KARL DEWEY said:
This assumes that Table1.TRADE_DATE and [Table1].[MATURITY_DATE] are DateTime
datatype.

WHERE Format([Table1].[TRADE_DATE],"yyyymm")<=[Rpt_Date] AND
Format([Table1].[MATURITY_DATE],"yyyymm")>[Rpt_Date];

--
KARL DEWEY
Build a little - Test a little


:

Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

Dan


PARAMETERS [Rpt_Date] DateTime;
SELECT Table1.P_SUBTP, Table1.BOOK, Table1.SOURCE_GL, Table1.HEDGE_TP,
Table1.POS, Table1.POS_SUBCAT, Table1.TAX_CLS, Table1.RE_PL, Table1.PTFOLIO,
Table1.DEALNO, Table1.USD, Table1.GBP, Table1.EUR, Table1.HKD, Table1.JPY,
Table1.SGD, Table1.CHF, Table1.AUD, Table1.ILS, Table1.CAD, Table1.ACTIVE_CD,
Table1.DEAL_TP, Table1.INSTR_TP, Table1.TRANS_TP, Table1.BOA, Table1.ORG,
Table1.GL_ACCT, Table1.S_ACCT, Table1.PRODUCT, Table1.COUNTR_NO,
Table1.COUNTR_NM, Table1.TRADE_DATE, Table1.START_DATE,
Table1.LT_MATURITY_DATE, Table1.MATURITY_DATE
FROM Table1
WHERE (((Table1.TRADE_DATE)<=[Rpt_Date]) AND
((Table1.MATURITY_DATE)>[Rpt_Date]));
 
J

John W. Vinson

Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

yyyymm is not a date field. A Date/Time value is a precise point in time (with
a day and a time; midnight assumed if not specified).

Assuming that you want to search a Date/Time field using this criterion, try
= DateSerial(Val(Left([Enter date as yyyymm:], 4)), Val(Right([Enter date as yyyymm:], 2)), 1) AND < DateSerial(Val(Left([Enter date as yyyymm:], 4)), Val(Right([Enter date as yyyymm:], 2))+1, 1)
 
K

KARL DEWEY

now I get an error?
You did not say what the error was.

Try removing PARAMETERS [Rpt_Date] DateTime; from the query.

--
KARL DEWEY
Build a little - Test a little


D said:
Hi Karl:

Please see the qry and table; now I get an error?

Thank you,

Dan

PARAMETERS [Rpt_Date] DateTime;
SELECT table1.ID, table1.Amt, table1.trade_date, table1.maturity_date
FROM table1
WHERE (((Format([Table1].[TRADE_DATE],"yyyymm"))<=[Rpt_Date]) AND
((Format([Table1].[MATURITY_DATE],"yyyymm"))>[Rpt_Date]));
***
ID Amt trade_date maturity_date
1 100 5/4/2008 12/13/2008
2 300 5/9/2008 10/6/2008
3 400 5/7/2008 9/8/2008
4 80 5/6/2008 8/7/2008
5 5 5/6/2008 7/6/2008

KARL DEWEY said:
I do not get the expected result
What do you get?

Post some sample data and example of results along with what you expect.

--
KARL DEWEY
Build a little - Test a little


D said:
Hi Karl:

Thank you!

Yes, trade date and maturity date are date/time data type; I have used your
criteria but I do not get the expected result; does not matter if I enter
200806 or 200806013 the result is the same??

Thanks again,

Dan

:

This assumes that Table1.TRADE_DATE and [Table1].[MATURITY_DATE] are DateTime
datatype.

WHERE Format([Table1].[TRADE_DATE],"yyyymm")<=[Rpt_Date] AND
Format([Table1].[MATURITY_DATE],"yyyymm")>[Rpt_Date];

--
KARL DEWEY
Build a little - Test a little


:

Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

Dan


PARAMETERS [Rpt_Date] DateTime;
SELECT Table1.P_SUBTP, Table1.BOOK, Table1.SOURCE_GL, Table1.HEDGE_TP,
Table1.POS, Table1.POS_SUBCAT, Table1.TAX_CLS, Table1.RE_PL, Table1.PTFOLIO,
Table1.DEALNO, Table1.USD, Table1.GBP, Table1.EUR, Table1.HKD, Table1.JPY,
Table1.SGD, Table1.CHF, Table1.AUD, Table1.ILS, Table1.CAD, Table1.ACTIVE_CD,
Table1.DEAL_TP, Table1.INSTR_TP, Table1.TRANS_TP, Table1.BOA, Table1.ORG,
Table1.GL_ACCT, Table1.S_ACCT, Table1.PRODUCT, Table1.COUNTR_NO,
Table1.COUNTR_NM, Table1.TRADE_DATE, Table1.START_DATE,
Table1.LT_MATURITY_DATE, Table1.MATURITY_DATE
FROM Table1
WHERE (((Table1.TRADE_DATE)<=[Rpt_Date]) AND
((Table1.MATURITY_DATE)>[Rpt_Date]));
 
D

D

Hi Karl:

The error was: The expression is too complicated....

Thanks,

Dan

KARL DEWEY said:
You did not say what the error was.

Try removing PARAMETERS [Rpt_Date] DateTime; from the query.

--
KARL DEWEY
Build a little - Test a little


D said:
Hi Karl:

Please see the qry and table; now I get an error?

Thank you,

Dan

PARAMETERS [Rpt_Date] DateTime;
SELECT table1.ID, table1.Amt, table1.trade_date, table1.maturity_date
FROM table1
WHERE (((Format([Table1].[TRADE_DATE],"yyyymm"))<=[Rpt_Date]) AND
((Format([Table1].[MATURITY_DATE],"yyyymm"))>[Rpt_Date]));
***
ID Amt trade_date maturity_date
1 100 5/4/2008 12/13/2008
2 300 5/9/2008 10/6/2008
3 400 5/7/2008 9/8/2008
4 80 5/6/2008 8/7/2008
5 5 5/6/2008 7/6/2008

KARL DEWEY said:
I do not get the expected result
What do you get?

Post some sample data and example of results along with what you expect.

--
KARL DEWEY
Build a little - Test a little


:

Hi Karl:

Thank you!

Yes, trade date and maturity date are date/time data type; I have used your
criteria but I do not get the expected result; does not matter if I enter
200806 or 200806013 the result is the same??

Thanks again,

Dan

:

This assumes that Table1.TRADE_DATE and [Table1].[MATURITY_DATE] are DateTime
datatype.

WHERE Format([Table1].[TRADE_DATE],"yyyymm")<=[Rpt_Date] AND
Format([Table1].[MATURITY_DATE],"yyyymm")>[Rpt_Date];

--
KARL DEWEY
Build a little - Test a little


:

Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

Dan


PARAMETERS [Rpt_Date] DateTime;
SELECT Table1.P_SUBTP, Table1.BOOK, Table1.SOURCE_GL, Table1.HEDGE_TP,
Table1.POS, Table1.POS_SUBCAT, Table1.TAX_CLS, Table1.RE_PL, Table1.PTFOLIO,
Table1.DEALNO, Table1.USD, Table1.GBP, Table1.EUR, Table1.HKD, Table1.JPY,
Table1.SGD, Table1.CHF, Table1.AUD, Table1.ILS, Table1.CAD, Table1.ACTIVE_CD,
Table1.DEAL_TP, Table1.INSTR_TP, Table1.TRANS_TP, Table1.BOA, Table1.ORG,
Table1.GL_ACCT, Table1.S_ACCT, Table1.PRODUCT, Table1.COUNTR_NO,
Table1.COUNTR_NM, Table1.TRADE_DATE, Table1.START_DATE,
Table1.LT_MATURITY_DATE, Table1.MATURITY_DATE
FROM Table1
WHERE (((Table1.TRADE_DATE)<=[Rpt_Date]) AND
((Table1.MATURITY_DATE)>[Rpt_Date]));
 
D

D

Hi John:

Thanks!

That would after where? how the qry will look like?

Dan

John W. Vinson said:
Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

yyyymm is not a date field. A Date/Time value is a precise point in time (with
a day and a time; midnight assumed if not specified).

Assuming that you want to search a Date/Time field using this criterion, try
= DateSerial(Val(Left([Enter date as yyyymm:], 4)), Val(Right([Enter date as yyyymm:], 2)), 1) AND < DateSerial(Val(Left([Enter date as yyyymm:], 4)), Val(Right([Enter date as yyyymm:], 2))+1, 1)
 
K

KARL DEWEY

Well what happened when you removed the declaration of the parameter?

It worked for me.


--
KARL DEWEY
Build a little - Test a little


D said:
Hi Karl:

The error was: The expression is too complicated....

Thanks,

Dan

KARL DEWEY said:
now I get an error?
You did not say what the error was.

Try removing PARAMETERS [Rpt_Date] DateTime; from the query.

--
KARL DEWEY
Build a little - Test a little


D said:
Hi Karl:

Please see the qry and table; now I get an error?

Thank you,

Dan

PARAMETERS [Rpt_Date] DateTime;
SELECT table1.ID, table1.Amt, table1.trade_date, table1.maturity_date
FROM table1
WHERE (((Format([Table1].[TRADE_DATE],"yyyymm"))<=[Rpt_Date]) AND
((Format([Table1].[MATURITY_DATE],"yyyymm"))>[Rpt_Date]));
***
ID Amt trade_date maturity_date
1 100 5/4/2008 12/13/2008
2 300 5/9/2008 10/6/2008
3 400 5/7/2008 9/8/2008
4 80 5/6/2008 8/7/2008
5 5 5/6/2008 7/6/2008

:

I do not get the expected result
What do you get?

Post some sample data and example of results along with what you expect.

--
KARL DEWEY
Build a little - Test a little


:

Hi Karl:

Thank you!

Yes, trade date and maturity date are date/time data type; I have used your
criteria but I do not get the expected result; does not matter if I enter
200806 or 200806013 the result is the same??

Thanks again,

Dan

:

This assumes that Table1.TRADE_DATE and [Table1].[MATURITY_DATE] are DateTime
datatype.

WHERE Format([Table1].[TRADE_DATE],"yyyymm")<=[Rpt_Date] AND
Format([Table1].[MATURITY_DATE],"yyyymm")>[Rpt_Date];

--
KARL DEWEY
Build a little - Test a little


:

Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

Dan


PARAMETERS [Rpt_Date] DateTime;
SELECT Table1.P_SUBTP, Table1.BOOK, Table1.SOURCE_GL, Table1.HEDGE_TP,
Table1.POS, Table1.POS_SUBCAT, Table1.TAX_CLS, Table1.RE_PL, Table1.PTFOLIO,
Table1.DEALNO, Table1.USD, Table1.GBP, Table1.EUR, Table1.HKD, Table1.JPY,
Table1.SGD, Table1.CHF, Table1.AUD, Table1.ILS, Table1.CAD, Table1.ACTIVE_CD,
Table1.DEAL_TP, Table1.INSTR_TP, Table1.TRANS_TP, Table1.BOA, Table1.ORG,
Table1.GL_ACCT, Table1.S_ACCT, Table1.PRODUCT, Table1.COUNTR_NO,
Table1.COUNTR_NM, Table1.TRADE_DATE, Table1.START_DATE,
Table1.LT_MATURITY_DATE, Table1.MATURITY_DATE
FROM Table1
WHERE (((Table1.TRADE_DATE)<=[Rpt_Date]) AND
((Table1.MATURITY_DATE)>[Rpt_Date]));
 
J

John W. Vinson

Hi John:

Thanks!

That would after where? how the qry will look like?

That would be on the Criteria line for the datefield in the query grid. Since
I have no idea how your table is structured I can't even guess at the SQL.

Dan

John W. Vinson said:
Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

yyyymm is not a date field. A Date/Time value is a precise point in time (with
a day and a time; midnight assumed if not specified).

Assuming that you want to search a Date/Time field using this criterion, try
= DateSerial(Val(Left([Enter date as yyyymm:], 4)), Val(Right([Enter date as yyyymm:], 2)), 1) AND < DateSerial(Val(Left([Enter date as yyyymm:], 4)), Val(Right([Enter date as yyyymm:], 2))+1, 1)
 
D

D

Here is the table John.

Thank you,

Dan

ID Amt trade_date maturity_date

John W. Vinson said:
Hi John:

Thanks!

That would after where? how the qry will look like?

That would be on the Criteria line for the datefield in the query grid. Since
I have no idea how your table is structured I can't even guess at the SQL.

Dan

John W. Vinson said:
Hi everyone/ Doug:

So. in the below qry; I would like to do all the comparisons based on year
and month: yyyymm; I need to enter when propted, yyyymm; how do I do that???

Thanks a lot!

yyyymm is not a date field. A Date/Time value is a precise point in time (with
a day and a time; midnight assumed if not specified).

Assuming that you want to search a Date/Time field using this criterion, try

= DateSerial(Val(Left([Enter date as yyyymm:], 4)), Val(Right([Enter date as yyyymm:], 2)), 1) AND < DateSerial(Val(Left([Enter date as yyyymm:], 4)), Val(Right([Enter date as yyyymm:], 2))+1, 1)
 
J

John W. Vinson

Here is the table John.

Thank you,

Dan

ID Amt trade_date maturity_date

SELECT ID, Amt, Trade_Date, MaturityDate
FROM tablename {which you didn't indicate}
WHERE {whichever date field you want to search, you didn't say that either} >=
DateSerial(Val(Left([Enter date as yyyymm:], 4)),
Val(Right([Enter date as yyyymm:], 2)), 1)
AND {datefield} < DateSerial(Val(Left([Enter date as yyyymm:], 4)),
Val(Right([Enter date as yyyymm:], 2))+1, 1) ;

Copy and paste this into the SQL window of a new query and replace the {}
phrases with the appropriate table and fieldnames.
 
D

D

Hi John:

Thank you!

Searching by the two dates.

Dan

John W. Vinson said:
Here is the table John.

Thank you,

Dan

ID Amt trade_date maturity_date

SELECT ID, Amt, Trade_Date, MaturityDate
FROM tablename {which you didn't indicate}
WHERE {whichever date field you want to search, you didn't say that either} >=
DateSerial(Val(Left([Enter date as yyyymm:], 4)),
Val(Right([Enter date as yyyymm:], 2)), 1)
AND {datefield} < DateSerial(Val(Left([Enter date as yyyymm:], 4)),
Val(Right([Enter date as yyyymm:], 2))+1, 1) ;

Copy and paste this into the SQL window of a new query and replace the {}
phrases with the appropriate table and fieldnames.
 
J

John W. Vinson

Hi John:

Thank you!

Searching by the two dates.

You'll need to use the same criterion on both datefields then, using OR logic.
Is it working for you? If not please post the SQL view of the query and let us
know what it's doing wrong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Parameter Query 5

Top