Solved

display days that have a specific month !!

Posted on 2002-04-06
14
209 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
Comment Utility
SELECT * FROM Table1 WHERE day LIKE '%-01-1979'

Build this string dinamically!
0
 

Author Comment

by:star5
Comment Utility
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
Comment Utility
I don't understand your comment.Did I answer your question. Where are the points?
0
 

Author Comment

by:star5
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
String sqlString="SELECT * FROM Table1 WHERE day LIKE '%-"+month+"-"year'";
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 3

Expert Comment

by:msterjev
Comment Utility
0
 

Author Comment

by:star5
Comment Utility
not working
0
 

Author Comment

by:star5
Comment Utility
it gives errors
0
 
LVL 1

Expert Comment

by:jose_tijo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
nestparen challenge 4 55
strCopies  challenge 17 73
where is session ID cache stored 1 37
mapAB Challlenge 35 83
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now