Search by date using showInputDialog

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Search by date using showInputDialog

Postby Thunder » Fri Apr 08, 2005 11:19 am

Hi all

I want to search a datetime field for all records <= a particular date. To try this, I did this in my method attached to a button:

var typedInput = plugins.dialogs.showInputDialog('Specify a date','up to and including date\n(use date in 25.12.2005 format)');
controller.find()
date_of_purchase = "<= typedInput"
controller.search()

The sybase datetime field "date_of_purchase" is formatted dd.MM.yyyy. My search does not work, it just finds all records - even though there are many records who's purchase date is after what I specify in the dialog.

I have tried date_of_purchase = "<=" + typedInput; - no joy. It still finds all 11 records (only one is before the date that I specify)

What am I doing wrong???

Thanks

Bevil[/i]
Thunder
 
Posts: 431
Joined: Thu Apr 24, 2003 10:33 am
Location: London

Postby Harry Catharell » Fri Apr 08, 2005 1:59 pm

Hi Bevil,

You were right to move the input variable out of the text string for the operator but you also need to tell the field what format your date is in as follows :
Code: Select all
date_of_purchase = "<= " + typedInput + '|dd-MM-yyyy';

so your method becomes:
Code: Select all
var typedInput = plugins.dialogs.showInputDialog('Specify a date','up to and including date\n(use date in 25-12-2005 format)');
controller.find() ;
date_of_purchase = "<= " + typedInput + '|dd-MM-yyyy';
controller.search()


See this thread which will certainly help:
http://forum.servoy.com/viewtopic.php?t=1349


Cheers
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby Thunder » Fri Apr 08, 2005 2:03 pm

thanks to the indefatigable help of JA, I was able to turn my brains back on and fix it. To future readers of this post, to save you being subjected to JA's SUD errors and etc., the solution was to join the field to the string (in my case |dd.MM.yyyy) with a + and put the string in quotes. i.e. date_of_purchase = '<=' + typedInput + '|dd.MM.yyyy'
Thunder
 
Posts: 431
Joined: Thu Apr 24, 2003 10:33 am
Location: London

Postby Thunder » Fri Apr 08, 2005 2:06 pm

Thanks Harry

I was able to get it sorted in exactly the way you said. Thanks..

Bevil
Thunder
 
Posts: 431
Joined: Thu Apr 24, 2003 10:33 am
Location: London


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 8 guests