This is sample my database:
-
status date
-
Q 2012-08-02.
- Q 2012-08-01.
- Q 2012-09-03.
Here if i run my application means i wish to display 2. This is do following information.
– check the database current month+status=Q after display how many matched information is totally you are got.for example totally 2 means the output is displayed 2.
Already i done get the total count value for current date+status=Q information.it is successfully completed.
Here i have use this code:
public class RetailerWs {
public int data(){
int count=0;
//count++;
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager
.getConnection("jdbc:mysql://localhost:3306/pro","root","");
PreparedStatement statement = con
.prepareStatement("select * from orders where status='Q' AND date=CURDATE()");
ResultSet result = statement.executeQuery();
while(result.next()) {
// Do something with the row returned.
count++; //if the first col is a count.
}
}
catch (Exception exc) {
System.out.println(exc.getMessage());
}
return count;
}
}
the another class is:
public class Demo {
public static void main(String[] args){
RetailerWs obj = new RetailerWs();
System.out.println(obj.data());
}
}
the above code for get the information for current date + status=Q.
please help me how is write the code for current month + status=Q….
It should be:
See THIS for more information on the date and time functions of MySQL.
For the week, try:
For the week in THIS year, try:
To have it all in one check use: