Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Cobol v2.1
  HXTT DBF v5.2
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

HXTT ACCESS
Problem in Selecting between a range of dates
Prasanna
2007-01-06 04:09:39.0
Dear Sir/Madam,

I faced a new problem,In select statement i used a range of dates say for

example i searched from Date >='2006-01-01' and Date<= '2006-02-31' .It retrieved

from January 1 st till March 3 rd.But i only want to retrieve only till february

28 th or 29 th if it is a leap year.But it return till 3rd march.I think i used 31

in the day so it added 3 values and retrieve 3 values (i.e) till 3rd march..How

to solve this problem.Please Help me!!!!


Regards

Prasanna.B

Re:Problem in Selecting between a range of dates
HXTT Support
2007-01-06 07:09:29.0
>example i searched from Date >='2006-01-01' and Date<= '2006-02-31' .
>It retrieved from January 1 st till March 3 rd.
Yeah. Because there's no 2-31, and Java will think it's March 3rd.
Changed it to
Date >='2006-01-01' and Date< '2006-03-01'
or
month(Date)<=2 and year(Date)=2006
Re:Re:Problem in Selecting between a range of dates
Prasanna
2007-01-07 23:09:31.0
Sorry for the late reply

Actually im connecting to the database from a web page through jsp.I get the

dates from the web page through drop down list.So in the day field it will be 1

to 31 days,suppose a user selects,

Starting Date: day field:1 month field:1 and year field : 2006

Ending Date : day field:31 month field:3 and year field : 2006

We have to display only from 1st jan till 28 feb.

If i implemented as u said ,Date>='2006-01-01' and Date<'2006-03-01' it will

be okay for these two months (i.e)jan till feb. But, suppose a user want the

details from 21st march to 21st april how to do that since we use lesser than

symbol it will ignore the particular day. How to implement this please give me

a solution.

Regards

Prasann.B
Re:Re:Re:Problem in Selecting between a range of dates
HXTT Support
2007-01-08 01:23:50.0
>How to implement this please give me a solution.
Then your issue is which you haven't verified and corrected the wrong input date, for instance, 2006-02-30 and 2006-03-31:)

You can use the following code to correct your date:

private static final java.sql.Date fixDate(String year,String month,String day){
Calendar calendar1=Calendar.getInstance();
int y=Integer.parseInt(year);
int m=Integer.parseInt(month)-1;
int d=Integer.parseInt(day);
calendar1.set(y,m,d);
if(calendar1.get(Calendar.DAY_OF_MONTH)!=d){
calendar1.setTimeInMillis(calendar1.getTimeInMillis()-calendar1.get(Calendar.DAY_OF_MONTH)*86400000);
}
return new java.sql.Date(calendar1.getTimeInMillis());
}


Re:Re:Re:Re:Problem in Selecting between a range of dates
Prasanna
2007-01-08 03:09:48.0
Thank u for your reply

Instead of that i wrote java script to validate the dates and also to check

whether the starting date is greater than the ending date.But i don't know how

to make the submit button disable until the dates are valid (or) to send only

valid dates.Any idea? Please give me some suggestion.

Regards

Prasanna.B
Re:Re:Re:Re:Re:Problem in Selecting between a range of dates
HXTT Support
2007-01-08 04:32:12.0

function checkDate() {
var myDayStr = document.CheckDate.formDate.value;
var myMonthStr = document.CheckDate.formMonth.value;
var myYearStr = document.CheckDate.formYear.value;
var myMonth = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); var myDateStr = myDayStr + ' ' + myMonth[myMonthStr] + ' ' + myYearStr;

/* Using form values, create a new date object
using the setFullYear function */
var myDate = new Date();
myDate.setFullYear( myYearStr, myMonthStr, myDayStr );

if ( myDate.getMonth() != myMonthStr ) {
alert( 'I\'m sorry, but "' + myDateStr + '" is NOT a valid date.' );
} else {
alert( 'Congratulations! "' + myDateStr + '" IS a valid date.' );
}
}


at http://www.csua.berkeley.edu/~jgwang/jsfunc02.htm
Re:Re:Re:Re:Re:Re:Problem in Selecting between a range of dates
Prasanna
2007-01-08 20:47:21.0
Thank you for your response.

I solved my problem..

HXTT tech support is very good in fast response and optimal solution.

Regards

Prasanna.B

Search Key   Search by Last 50 Questions




Google
 

Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Email: webmaster@hxtt.com
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap