Share on Google+Share on Google+

pradeep
date problem in sql server
1 Answer(s)      7 years ago
Posted in : SQL
select count(*) from xxxx_tbl where emplid="+emplid+" and work_dt=#"+work_date+"#"; work_date is in string ,Backend is sql server 2000.i am getting the date problem when using in jsp page.

Ads

View Answers

March 31, 2010 at 12:06 PM


Hi Friend,

Try the following code:

retrieveDate.jsp:

<[email protected] import="java.sql.*"%>
<form method="post" action="retrieveDate.jsp">
<table>
<tr><td>ID</td><td><input type="text" name="id"></td></tr>
<tr><td>Work Date(yyyy-MM-dd)</td><td><input type="text" name="d"></td></tr>
<tr><td><input type="submit" value="Submit"></td></tr>
</table>


<%
String ide=request.getParameter("id");
String date=request.getParameter("d");


String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/test";;

String GET_RECORD = "select count(*) from d where id='"+ide+"' and myDate='"+date+"'";
ResultSet rs = null;
Connection conn = null;
Statement stmt = null;
try {
Class.forName(driver);
conn=DriverManager.getConnection(url, "root", "root");

stmt = conn.createStatement();
rs = stmt.executeQuery(GET_RECORD);
while (rs.next()) {
out.println("Count =" + rs.getString("count(*)"));
}
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
%>

Thanks









Related Tutorials/Questions & Answers:
date problem in sql server - SQL
date problem in sql server  select count(*) from xxxx_tbl where emplid="+emplid+" and work_dt=#"+work_date+"#"; work_date is in string ,Backend is sql server 2000.i am getting the date problem when using in jsp page.  
JSF Tomahawk date problem - Java Server Faces Questions
JSF Tomahawk date problem  hi i am working with jsf. I have one doubt reg Tomahawk input Date and Input calender tags. I am trying to get... full details with source code to solve the problem and visit to : http
Advertisements
SQL Server
SQL Server  Hii, What is SQL Server ?   hello, SQL Server is a DBMS system provided by Microsoft
date range in sql
date range in sql  How can I select a random date from a date range in SQL server
sql server - SQL
sql server  what is SQL server? & what is oracle? are they same
sql server - SQL
sql server  How many no of tables can be joined in same sql server
Sql Server - SQL
sql server trigger example  Can any one tell me the live example of triggers in SQL Server?   if u click pistal trigger ,it auotmatically shoot bullet it's like newtons 3rd law (every action s having an equal reaction
php sql problem - SQL
php sql problem  I ahve a php code that doesn't allow me to get the vat value from db. i tried to add $vat = 21; below $shippingCost = 10... NOW() is problem
Data Conversion In Sql Server 2005
Data Conversion In Sql Server 2005  Hi I am working vb.net & sql server 2005 database. I am storing date (MM/DD/YYYY) format. now I have problem in sql date conversion (DD/MM/YYYY). Can you help how to convert date
SQl Date
SQL Date       The SQL Date is used when you are working with dates. This include... The Tutorial illustrate a Example from SQL Date. In this Tutorial, we
Select today's date sql
Select today's date sql   I wanted to show the data from database according to the current date. So, can anyone give me the select today's date sql query? Thanks!   select current date in mysql query select * from
SQL date query
SQL date query  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d %M
SQL SERVER 2008
SQL SERVER 2008  when i am fill the all fields in the form.but when i am retrive from the database it shows only firstname,age,address.remaining... wiil be happened here.Tell me the solution for this problem as quickly
Multi-Date Handling Problem
Multi-Date Handling Problem  In our project we are using Oracle 10g as our data base, the problem is that we are picking In-date & Out-date from a calendar and on the basis of that date we are checking that on that date some
XML in SQL Server
XML in SQL Server  Hi..... please anyone tell me about What is the purpose of FOR XML in SQL Server? Thanks
SQL get start date and end date result
SQL get start date and end date result  how to get ( 15 march 2011) and (15/03/2011) output using SQL
SQL Between Date
SQL Between Date       The Tutorial help you to understand SQL Between Date. In this Tutorial..._Table (Stu_Id varchar(2), Stu_Name varchar(15), Stu_Dob date); Insert Data
Java to SQL Server Connectivity
Java to SQL Server Connectivity  Hi, heres my code private void... with sql server connectivity at the background to save the data. Now, after..._name,cust_nic,cust_contact,cust_address,seat_no,departure_date,amount,total_amount
SQL display date in between query
SQL display date in between query  how to get ( 15 march 2011) and (15/03/2011) output using SQL
SQL Date, SQL Date Examples
SQL Date       In this we are going to discuss about the SQL Date functions. SQL stands... will be able to use the SQL Date functions effectively in your program. Here
date problem - Java Beginners
date problem  how to extract day,month,year hours ,second from a string date. Examples: String dat ="200912202934" from this string extract month ,year,date,hours,minute Please help me. Thanks in advance Sushil 
MySql date problem
MySql date problem  with a mysql query, how can you get records of previous week dynamically, starting from sunday and ending on saturday? I don't want records from current date, just the previous week
tomcat server problem
tomcat server problem  hello rose india, my name is raju. I am placing a problem with tomcat5.5 server. when i am trying to execute my project I... page is appeared. please resolve my problem as soon as possible. thanking you
date problem - Java Beginners
date problem  how to extract day,month,year hours ,second from a string date. Examples: String dat ="200912202934" from this string extract month ,year,date,hours,minute Please help me. Thanks in advance Sushil 
problem with the installation of apache-geramio2.1 server
problem with the installation of apache-geramio2.1 server  i have installed Apache Geronimo 2.1 server on my pc,but desired page is not coming on the BROWSER after typing localhost:8080 on the contrary oracle page
Merge databases in SQL SErver 2005
Merge databases in SQL SErver 2005  Please help me to merge databases in SQL server 2005
Sql Server 2008 with textbox
Sql Server 2008 with textbox  **Hi, I tried to insert into DB using textbox in a form using vb by visual studio 2010 but its always catch an error... myconn = New SqlConnection("server=localhost;" & "Initial Catalog=4
Weblogic8 server problem
Weblogic8 server problem  Hi, I am getting following problem while executing client code fro EJB2 in weblogic8 server. Please solve this problem. javax.naming.NameNotFoundException: Unable to resolve 'JLCHelloHomeJNDI
j2me problem - SQL
j2me problem  Hi i hava a j2me (mobile application) having 3 forms each one having 4 fields(text box and dropdown ).i want to get the data from thouse fields, and store into sql data base in my local pc. How intract
server problem - EJB
server problem  Dear sir please give me full deatil how intall jboss5.1.0 and how compile application -ejb,hibernate,spring for admestration console and how intall jboss5.1.0GA server and i not found ant(compiler) thanks
server problem - Hibernate
server problem  dear sir please give me best soloution how run hibernate and spring application on jboss and weblogic10.1.0 sever and compile thanks
Tutorials   
Java Spring Hibernate Struts Training How to Fetch Data using dropdown option How to get day from date in SQL? Example of sorting results in MySQL Distinct and Limit example in MySQL How to download install and use MySQL workbench? Example of Average, Sum, Min and Max functions in MySQL How to delete data from MySQL? Update SQL Query Example Order by example in MySQL AND and OR Operators in MySQL Query Where clause with query in MySQL How to use select Statement in MySQL? How to insert data into MySQL Table? Create Database and tables in MySQL example of before insert trigger in mysql Failed to Call Procedure MY Sql Query Error - Not able to Understand the issue which query will be run for previous(button) question How to access data yearly from DB in C# ? Fastest way to upload huge raw data in database - c#, Java or stored procedure DB Insert Nb hours between 2 time stamps meets specific criteria mysql select into table from another table example MySQLselect into new table Example code How to create a .mdf file from script (.sql) Please help me out fixing broken relational links in MySQL database after an upgrade How do I upgrade mysql? mysql 4.x to 5.x upgrade problem Upgrading a PHP/MYSQL application? upgrading sql query join phpmyadmin in whm whm php version update php cpanel cpanel mysql downgrade cpanel mysql version upgrade mysql whm upgrade mysql 4 5 cpanel upgrade mysql cpanel server Did my upgrade from mySQL 5.1 to 5.5 work Upgrade to MySQL 5.5 ? - cPanel Mem use upgrade from MySQL 5.1 to 5.5 - cPanel Upgrading MySQL from 5.0 to 5.1 or 5.5 - cPanel Mysql Upgrade on WHM (Mysql 5.1 to 5.5)cPanel Mysql Upgrade on WHM (Mysql 5.1 to 5.5) - cPanel Updating from MySQL 5.0 to 5.5 cPanel MySQL 5.1 upgrade to 5.5 error Charset problem upon publishing PHP + MySQL website MySQL issue: Table 'data_dictionary.CHARACTER_SETS' doesn't exist SQL Error Version 5.5.15

Ads

 
Advertisement null

Ads