date calculation

Questions, tips and tricks and techniques for scripting in Servoy

date calculation

Postby Harjo » Fri Jun 06, 2003 3:49 pm

In Filemaker I do:

Field: Datum1(date)
Field: Datum2(calculation) Datum1 + 1

If I fill in Datum1 then Datum returns automaticly the next day.
How can this be done in Servoy?
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby Ron » Fri Jun 06, 2003 4:58 pm

Nasty problem,

Have you tried something with getDate() (see: JS-LIB)
This returns a daynumber, so you can make a calculation with the days.
Now you have to reconstruct the date itself.
I haven't been able to do this up till now...
Edward, help us plse.
Ron
 
Posts: 315
Joined: Fri May 23, 2003 12:30 am
Location: Netherlands

Postby edward » Fri Jun 06, 2003 5:07 pm

Good ol JavaScript

var a = new Date();
a.setDate(a.getDate()+1);
Edward Callaghan
Servoy
edward
 
Posts: 142
Joined: Wed Apr 23, 2003 9:35 pm
Location: London, UK

Postby Harjo » Sun Jun 15, 2003 12:46 pm

Hi Edward,

I trying to implement this, but it won't work.

I have a global: date1
and the following (stored) calculation: date2

If I type for example in date1: 15-06-2003
I want that date2 is automaticly calculated to: 16-06-2003

what is the calculation of: date2?
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby jcompagner » Mon Jun 16, 2003 5:03 pm

the calculation script of date2 should be:

var a = date1;
a.setDate(a.getDate()+1);
return a;

or the short version should also work:

return date1.setDate(date1.getDate()+1);
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby maarten » Fri Jul 04, 2003 8:20 pm

Here's a link to a couple of usefull date related javascripts.
http://www.lowcostweb.us/scripts/
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 15 guests