Button method for searching by month

Questions, tips and tricks and techniques for scripting in Servoy

Button method for searching by month

Postby Westy » Fri Feb 13, 2004 5:54 am

With a simple table that has a date column and a few text columns what is the best way in Servoy to create a list that will allow the user to click one of a group of buttons on the header named Jan, Feb, Mar, etc. that will search for all records with a corresponding month in the date column? A sample button method that can achieve this is all I need.
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Postby Harjo » Fri Feb 13, 2004 10:57 am

here is how I do it:

create a global field: maanden (months)
create a global field: jaar (year)

create a valuelist: vl_maanden:
All|0
Jan|1
Feb|2
Maa|3
Apr|4
Mei|5
Jun|6
Jul|7
Aug|8
Sep|9
Okt|10
Nov|11
Dec|12
and attach it to global: maanden and make the field: RADIOS

create a valuelist: vl_jaar

2003
2004
2005
2006
2007
2008
2009
2010

and attach it to global: jaar and make the field: combobox

here is the method:
Code: Select all
var month = globals.maanden
var year = globals.jaar
var endOfMonth = new Array('31-01','28-02','31-03','30-04','31-05','30-06','31-07','31-08','30-09','31-10','30-11','31-12');

if (  ( (year % 4 == 0) && (year % 100 != 0) ) || (year % 400 == 0)   ) {endOfMonth[1] = "29-02"};

controller.find();
if(globals.maanden == "0" && globals.jaar != "")
{
   offertedatum = '01-01-'+year+'...31-12-'+year+'|dd-MM-yyyy'
}
if(globals.maanden != "0" && globals.jaar != "")
{
   offertedatum = '01-'+month+'-'+year+'...'+endOfMonth[month-1]+'-'+year+'|dd-MM-yyyy'
}
controller.search()


Hope this helps
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Button method for searching by month

Postby Westy » Fri Feb 13, 2004 5:28 pm

Thank you very much. That was exactly what I needed! :D
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Postby grahamg » Fri Feb 13, 2004 5:47 pm

An alternative to the method suggested by the esteemed HJK.

Date field [dated]
Calculated integer field [yyyymm] = return (dated.getFullYear() * 100) + (dated.getMonth() + 1);

This converts the [dated] field into 200312, 200401, 200402 etc etc.

Month selection field [SelectDate] based on value-list using [yyyymm] field.

If users not comfortable with choosing 200402 for Feb 2004 you could add another calculated field to display Month_Year in text.

Hope this helps

Graham Greensall
grahamg
 
Posts: 752
Joined: Fri Oct 03, 2003 3:15 pm
Location: Midlands UK


Return to Methods

Who is online

Users browsing this forum: Bing [Bot] and 33 guests

cron