Searching on DATETIME fields

Questions, tips and tricks and techniques for scripting in Servoy

Searching on DATETIME fields

Postby mattman » Tue Feb 03, 2004 7:49 am

This has probably been asked before, but I thought some clarification might be needed for others who will hit these issues.

I feel the following code should obey the order following it. Servoy should make assumptions about a method that attempts an automated find.

Code: Select all
currentcontroller.find();

var today = new Date();
var searchDate = utils.dateFormat(today, 'MM-dd-yyyy')

forms.mag_subs.subs_renewdate = searchDate;

currentcontroller.search();


1. If the field being searched on the form has a format assigned to it, and is a displayType CALENDAR, (such as MM/dd/yyyy) then the field should require/obey that format.

2. If the field being searched on the form has no format assigned then it should default to the setting in Preferences > Locale
> Date Format

3. We should be able to use a function like getLocaleDateFormat() found under the Application object so we can coerce dates in functions like utils.dateFormat() -This addition would anticipate localization issues that should be added for international versions of Servoy front ends. Using a table to determine time zone offsets and comparing against a local clock should allow the adjustment of date formatting.

P.S. Yes, I found this post http://forum.servoy.com/viewtopic.php?t=776 but I think formatting on date fields should have overrides for searching. I do know that the code above has to be formatted as such in order to work...

Code: Select all
currentcontroller.find();

var today = new Date();
var searchDate = utils.dateFormat(today, 'MM-dd-yyyy')

forms.mag_subs.subs_renewdate = searchDate + '|MM-dd-yyyy';

currentcontroller.search();
Attachments
bad_date_format.jpg
Bad date dialog.
bad_date_format.jpg (17.62 KiB) Viewed 1663 times
Matt Petrowsky
mattman
 
Posts: 160
Joined: Wed Aug 06, 2003 8:23 am
Location: Murrieta, CA

Postby jcompagner » Wed Feb 04, 2004 11:25 pm

in javascript you don't work with fields but only with dataproviders.. So we can't say

forms.mag_subs.subs_renewdate

should work with the fieldY's format...

Because we don't know that the dataprovider is shown for that field in javascript.. Those 2 are completely seperated...

what should we do for example if there are 2 or 3 fields with different formats for that dataprovider??

For this we need something like a format bound to a dataprovider.. (and then fields are using that by default)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: No registered users and 27 guests