Cancel
Showing results for 
Search instead for 
Did you mean: 

date and dateTime default argument

Legend
Legend

Hello,

 

I try to use a date as default argument for a method.

 

I read in the help that : " Parameters of data type date or datetime cannot have a default argument at all "

 

Why this 2 type cannot have a default value while time can ?

And Why I cannot write this :

var testDate : Date := 01/01/2017

 

Regards,

 

rpinon

 

 

 
4 REPLIES 4

Re: date and dateTime default argument

Siemens Phenom Siemens Phenom
Siemens Phenom

Because 2017/01/01 is actually 2017 divided by 1 divided by 1, which is the real number 2017.

You would need to write something like this:

param d : date := str_to_date("2017/01/01")

 

This is not possible, because the default value must be a constant and cannot be the result of a function call.

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: date and dateTime default argument

Legend
Legend

And if I write

param testDate : Date := 0 -- 01/01/1970

 

Regards,

 

rpinon

Re: date and dateTime default argument

Siemens Phenom Siemens Phenom
Siemens Phenom

0 is a number and not a date. You probably already tried it and got a runtime error.

The online help clearly states that a date cannot have a default value. Why do you try anyway?

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: date and dateTime default argument

Legend
Legend

I don't try it because I know that it's not possible.

 

But in 14.0 you have integrated the time format => 2:0:0 

 

So why  didn't you do this with the date and the dateTime.

 

I understand that 1/1/2017 is a division but can we use a real value that is automaticaly casted in date or dateTime like in excel.

 

Regards,

 

rpinon