Finding date range not working correctly

Hi all,

I have a valuelist as follows that I’m trying to use to filter out records by a due date:

All|0
This Week|1
Next Week|2
> Two Weeks|3

For some reason the method I’m using (called by onAction) is not returning any records, and I’m not sure why. Here are some sample search strings that are output (dynamically generated):

#3-10-2008...3-17-2008|M-d-yyyy
#3-10-2008...3-17-2008|MM-dd-yyyy // tried this formatting too
>=#3-24-2008|M-d-yyyy // ..and this

I don’t need to have the time component, so I added the # operator. I have dates in the normal datetime format and am using Sybase Anywhere, the default database.

Any ideas on what’s going on? I’ll put a part of my method below for more information. TIA!

switch (globals.g_dateSearch)
{
	// ...
	// Searches for actions due in the next 7 days
	case 1:
		controller.find();
		var d = new Date(); // get current date and time
		var day = d.getDate(); // gets day of month
		var month = d.getMonth() + 1; // JS Date goes from 0 to 11
		var year = d.getFullYear();

		var d_final = new Date();
		d_final.setTime(d.getTime() + (7*24*60*60*1000) ); // add one week
		
		var day_final = d_final.getDate();
		var month_final = d_final.getMonth() + 1; // JS Date goes from 0 to 11
		var year_final = d_final.getFullYear();
		
		due_date = "#" + month + "-" + day + "-" + year + "..." + month_final + "-" + day_final + "-" + year_final + "|MM-dd-yyyy";
		controller.search();
		break;

//...

If I am correct only formatting should be enough (no #)…

MM-dd-yyyy
```Will not work in your example since that needs date input like 03-10-2008.

Why don't you do this with a query?

Try it without “#” - it should work. And you should be able to do it without the “#” since this is an interval search: from day “x” midnight to day “y” midnight.

Hi aron,

Andrei is rigth.

without “#” - it should work. And you should be able to do it without the “#” since this is an interval search: from day “x” midnight to day “y” midnight

Thank you all for the quick responses, apologies for the late reply.

Turns out the # was indeed causing problems; seems to work fine now.