how to retrieve the data based on the difference between the start date and end date(2 columns)
how to retrieve the data based on the difference between the start date and end date(2 columns)
vaishnavkoka
Posts: 132Questions: 23Answers: 1
I am only able to retrieve the data based on the the date of single column, but i would like to get the result based on two columns. here is an example :http://live.datatables.net/sewehuwe/1/
it should be something like select * from tableName where startdate='somedate' and enddate='somedate';
This discussion has been closed.
Answers
Hi @vaishnavkoka ,
If you're doing as a table search, you can just search on each of the columns individually with
column().search()
. If you just want the data, you would need to go through the rows withrows().every()
and filter them out that way.Cheers.
Colin
Hi @colin ,
I want the data to be shown when i insert a date in minimum date field and maximum date field, i.e., i want to retrieve the data based on this two parameters. If you look at the above example it just shows the data for a single column only, which is no way helpful to me.
Hi @vaishnavkoka ,
I understand, it sounds like you want to use a range type search, as with the example here. There's a plugin specifically for date ranges, see here.
Cheers,
Colin
Hi @colin ,
I tried but i didnt get the output, i even changed the ids as mentioned in the page you suggested but still it doesnt work.
Here is the link:
http://live.datatables.net/vocivoji/40/edit
Hi @vaishnavkoka ,
You really need to debug that script. If you look in the console you'll see many errors - things which are easily caught (for example, you have
document.getElementById('fini')
but no element with the IDfini
.Cheers,
Colin
Hi @colin , oh yeah i forgot to change them, even after changing i am not getting the output.
Thanks,
Koka
OK, could you link to your changed one, please.
Oh yeah, here it is:
http://live.datatables.net/lawowito/1/edit
I am not sure where did i go wrong looking forward to get a solution from you.
Hi @vaishnavkoka ,
I just tried that link you posted above and there are still console errors. I've removed those in this example here.
Try adding some debug into those
if
statements, and that may help to understand what's going on. If you have no joy, let me know, and I'll see I can poke some more tomorrow.Cheers,
Colin
Hi @colin ,
I tried and it always gets into the first "if" statement, as i have already explained the requirement would you mind helping me out with the solution ?
Hi @vaishnavkoka ,
I just took another look, see here. The problem is that the dates are in different format, so they're being parsed incorrectly. As this will be your data, you need to ensure the format is consistent and what you want for your users, then adapt the code accordingly.
Cheers,
Colin
Hi @colin ,
Though i changed the format still it didnt work.
Can you give us a link to an updated test case please.
Hi @alan,
Here is the link :
http://live.datatables.net/lawowito/3/edit
beside this date field i would like to use drop down list for "Position" separately, so when i select the dates and a value from a drop down list such as "Director" i should able to get the result on the datatable.
Thanks
Koka
Your data has some invalid dates. For example, 07/092012.
Hi @tangerine ,
http://live.datatables.net/zomemoya/1/edit
you can check now, i still did not the required results.can you help me solve this issue?
Thanks
Koka
You really need to examine your data for consistent dd/mm/yyyy format.
date is in mm/dd/yyyy format and i entered in the same format, on your saying i changed the date values
http://live.datatables.net/zomemoya/1/edit
and still it didnt work.
Can you tell me where did i go wrong ?
So you are storing dates as mm/dd/yyyy, and trying to filter them using dd/mm/yyyy?
no , i am storing dates as mm/dd/yyyy and trying to filter them using the same format as mm/dd/yyyy.
http://live.datatables.net/zomemoya/3/edit
I'm seeing that for the input too @tangerine. I think its a localisation thing since its a
<input type="date">
element - with US locale it would show as mm/dd/yyyy for example.There were errors on the page, such as loading jQuery twice, using a date range plug-in file that wasn't needed, etc. Tidying it up allow allows it to run: http://live.datatables.net/zomemoya/4/edit .
This bit is still wrong:
The
input type="date"
field will give you the date in ISO8601 format - i.e. YYYY-MM-DD. You need to change your conversation from the current style (which is UK, even although you are trying to use US formatting...) to match the ISO format.Likewise your decoding of the US style dates from the table are attempting to do UK date decoding, which is obviously not what you want to do and I'm not clear why you'd split the string like that.
If you would like one of us (Colin or I) to get it working for you, priority support is available.
Allan