How to write an "if Date" ?

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

How to write an "if Date" ?

Postby cuoredisardegna@tiscali.i » Sat May 08, 2004 8:49 am

In a form orders i have a field calculation named “order_date” in which i writed:

now = new Date()
return now ;

Every time that i start orders the field “order_date” is autofilled with today_date, also if i am calling
a row in wich was stored a precedent date.

How have i to write an if statment so that

only if (order_date is empty)

today_date is returned ?


The question may be stupid but i am beginner.

Tanks in advance

___________________
Gianni Pinna
cuoredisardegna@tiscali.i
 
Posts: 151
Joined: Sun Feb 29, 2004 10:35 pm
Location: Sassari

Postby automazione » Sat May 08, 2004 9:13 am

if (order_date == null)

should work

ciao
Enrico Arata
Servoy Italia
automazione
 
Posts: 366
Joined: Thu Apr 24, 2003 11:37 am
Location: Torino, Italy

Post subject: How to write an "if Date" ?

Postby cuoredisardegna@tiscali.i » Sat May 08, 2004 10:19 am

Dear Enrico,

You are always very prompt and kind.

Have You what Yoy wish.
Ciao.

_____________
Gianni Pinna
cuoredisardegna@tiscali.i
 
Posts: 151
Joined: Sun Feb 29, 2004 10:35 pm
Location: Sassari

Postby cuoredisardegna@tiscali.i » Sat May 08, 2004 11:15 am

Dear Enrico,
I writed in calculation field order_date:

var now = new Date() ;
if (order_date == null)
{
return now ;
}

But i had 2 effects:
1) Order_date which is second field in the form is displayed empty;
2) First field which normally is autofilled is dispalyed empty too.
What error do i make?

Tanks in advance
_________________
Gianni Pinna
cuoredisardegna@tiscali.i
 
Posts: 151
Joined: Sun Feb 29, 2004 10:35 pm
Location: Sassari

Postby automazione » Sat May 08, 2004 6:06 pm

if (order_date == null)
{
order_date = new Date();
}

should work.

I am not able to understand what you are trying to do, but:

I think default values for global variables can be defined only if global are text or integer.. not datetime or media

If your problem is on a calculation field, be carefull to select it as a datetime

it the problem is on a method, the debugger can be of great help in finding problems with the application

Hope this help, ciao
Enrico Arata
Servoy Italia
automazione
 
Posts: 366
Joined: Thu Apr 24, 2003 11:37 am
Location: Torino, Italy

How to write an "if Date" ?

Postby cuoredisardegna@tiscali.i » Sat May 08, 2004 7:31 pm

Enrico,

tanks again. With a method I solved problem

var now = new Date() ;
if (order_date == null)
{

order_date = now
}

I have :
1) associated method to on focus gain of order_date:
2) made order_date : autoenter creationDateTime.

Now i am going to experiment with Your suggestions and making order_date as calculation field.

Tanks again
Ciao
__________
Gianni Pinna
cuoredisardegna@tiscali.i
 
Posts: 151
Joined: Sun Feb 29, 2004 10:35 pm
Location: Sassari

Postby jcompagner » Sat May 08, 2004 8:41 pm

why do you need an method that checks for null?
if you have autoenter set on the order_date column it should always be filed in.
isn't that the case?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

How to write an "if Date"

Postby cuoredisardegna@tiscali.i » Sun May 09, 2004 11:43 am

Dear Jcompagner,
tanks for Your question, it may be that i have solved
the problem in a redundant way.
My intention was of :
1) having order_date in new rows without rewriting order_date in old rows.
a) This was not possible with a calculation field [ var now = newDate() ;
return now;]
b) So i writed a metod as described, and it was right in order to my
intention. But the date was not autofilled in order_date, but,
although it was filled when i clicked on order_date in the form.
c) At this point i experimented with autoenter set in the order_date
column and i obtined my intention.

This is the way, but now, after Your question, i'll try without method.

_________________
Best regards
Gianni Pinna
cuoredisardegna@tiscali.i
 
Posts: 151
Joined: Sun Feb 29, 2004 10:35 pm
Location: Sassari


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 6 guests