Solved

display days that have a specific month !!

Posted on 2002-04-06
14
213 Views
Last Modified: 2013-11-24
suppose i have table that contains days
like 26-01-1979 and i want to display all the days that
have the same month and year .

for example :12-01-1979 , 04-01-1979
by using sql command and java servlet
0
Comment
Question by:star5
  • 7
  • 5
  • 2
14 Comments
 
LVL 3

Expert Comment

by:msterjev
ID: 6923513
SELECT * FROM Table1 WHERE day LIKE '%-01-1979'

Build this string dinamically!
0
 

Author Comment

by:star5
ID: 6923574
this is fixed !!
SELECT * FROM Table1 WHERE day LIKE '%-01-1979'

the day should be entered by the user
into two texts: one holds the month ,the other holds the year
0
 
LVL 3

Expert Comment

by:msterjev
ID: 6923584
I don't understand your comment.Did I answer your question. Where are the points?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:star5
ID: 6924080
no u didn't answer the Question,
what u are suggesting is for fixed day
the day should be a variable that can be entered by the user.
the user enter the name of the month in a text and the year in another text

SELECT * FROM Table1 WHERE day LIKE 'user entered day'

0
 
LVL 3

Expert Comment

by:msterjev
ID: 6924622
String month=Request.getParameter("month");
String day=Request.getParameter("year");
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-"+month+"-"year";
0
 

Author Comment

by:star5
ID: 6924861
are sure about this code
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-"+month+"-"year";

i think there is a mistake in the quataion marks ""
would u check it please ,
i think it well work
0
 
LVL 3

Expert Comment

by:msterjev
ID: 6924939
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-"+month+"-"year'";
0
 
LVL 3

Expert Comment

by:msterjev
ID: 6924944
0
 

Author Comment

by:star5
ID: 6927376
not working
0
 

Author Comment

by:star5
ID: 6927393
it gives errors
0
 
LVL 1

Expert Comment

by:jose_tijo
ID: 6927489
String month=Request.getParameter("month");
String day=Request.getParameter("year");
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-" + month + "-" + year;
0
 

Author Comment

by:star5
ID: 6927893
not working jose_tijo it shows an error .
some missing Quationts or apostofe
0
 
LVL 1

Accepted Solution

by:
jose_tijo earned 5 total points
ID: 6927908
Hi

Try this star5

String month=Request.getParameter("month");
String day=Request.getParameter("year");
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-" + month + "-" + year + "'";

Tijo
0
 

Author Comment

by:star5
ID: 6928017
when i used :
int month=9;
int year=2001;
   
strSQL="SELECT * FROM Training WHERE startdate LIKE '"+month+"/"+"%"+"/"+year+"'";

it works correctly
note :i'm using doget


but when i tried to read the values from an html page
it shows errors, the html page has method = post

int month;
int year;
month = req.getParameter(month);  
strSQL="SELECT * FROM Training WHERE startdate LIKE '"+month+"/"+"%"+"/"+year+"'";

what is wrong with this
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delete Android all or certain applications data programmatically 9 106
ejb entity bean example 2 31
Tagging and Merging on Branch 1 39
spring maven example issues 3 37
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question