Board index » delphi » Reporting based on month of date

Reporting based on month of date

Please Help.

   This statement will print the data based on Date.

   form1.Query1.close;
   form1.Query1.ParamByName('var1').asDate :=DateTimePicker1.Date;
   form1.Query1.ParamByName('var2').asDate :=DateTimePicker2.Date;
   form1.Query1.prepare;
   form.Query1.ExecSQL;
   form1.query1.open;
   Form1.QuickRep1.Preview;

On the Query statement I wrote :

SELECT Table1."Name" , Table1."Address" ,
 Table1."DateofBirth"
FROM "Table1.db" Table1
WHERE ( ( Table1."DateofBirth" >=  :var1 ) AND
  ( Table1."DateofBirth" <=  :var2 ) )
ORDER BY
 Table1."DateofBirth"

How could I add a statement that will print based on Month of Date using
query?
example : All people who born on October without year or day of birth.
Just the month of birth. So Quick Report will print all people who born
on October.

Thank you for responding.

 

Re:Reporting based on month of date


There is an EXTRACT function you can use in SQL statements.See you Local SQL
help.

Cezar Nechifor

Quote
pramono wrote:
> Please Help.

>    This statement will print the data based on Date.

>    form1.Query1.close;
>    form1.Query1.ParamByName('var1').asDate :=DateTimePicker1.Date;
>    form1.Query1.ParamByName('var2').asDate :=DateTimePicker2.Date;
>    form1.Query1.prepare;
>    form.Query1.ExecSQL;
>    form1.query1.open;
>    Form1.QuickRep1.Preview;

> On the Query statement I wrote :

> SELECT Table1."Name" , Table1."Address" ,
>  Table1."DateofBirth"
> FROM "Table1.db" Table1
> WHERE ( ( Table1."DateofBirth" >=  :var1 ) AND
>   ( Table1."DateofBirth" <=  :var2 ) )
> ORDER BY
>  Table1."DateofBirth"

> How could I add a statement that will print based on Month of Date using
> query?
> example : All people who born on October without year or day of birth.
> Just the month of birth. So Quick Report will print all people who born
> on October.

> Thank you for responding.

Re:Reporting based on month of date


how about this:

select name,address,dateofbirth,month=datepart("m",dateofbirth)
from table1
where (YOUR CONDITION) and month=10

or by group:
select name,address,dateofbirth,month=datepart("m",dateofbirth)
from table1
where (YOUR CONDITION)
group by month

pramono

Quote
> Please Help.

>    This statement will print the data based on Date.

>    form1.Query1.close;
>    form1.Query1.ParamByName('var1').asDate :=DateTimePicker1.Date;
>    form1.Query1.ParamByName('var2').asDate :=DateTimePicker2.Date;
>    form1.Query1.prepare;
>    form.Query1.ExecSQL;
>    form1.query1.open;
>    Form1.QuickRep1.Preview;

> On the Query statement I wrote :

> SELECT Table1."Name" , Table1."Address" ,
>  Table1."DateofBirth"
> FROM "Table1.db" Table1
> WHERE ( ( Table1."DateofBirth" >=  :var1 ) AND
>   ( Table1."DateofBirth" <=  :var2 ) )
> ORDER BY
>  Table1."DateofBirth"

> How could I add a statement that will print based on Month of Date using
> query?
> example : All people who born on October without year or day of birth.
> Just the month of birth. So Quick Report will print all people who born
> on October.

> Thank you for responding.

Re:Reporting based on month of date


See the Extract function in the Local SQL help file for information on
extacting part of a date.

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Other Threads