TextBox Default Date Value

TextBox Default Date Value

  
I set an Input control (inside a editable table) default (null value property) to a variable that set to CurrDate()
CurrDate works and the variable shows the current date.

Null property ignores the variable and inserts 01/01/1900

PS
I have also tried setting the preparation of the inputcontrol to CurDate and it still comes out as 01/01/1900



You have to remember that on the Outsystems platform a null date is defined as #1900-01-01#, not null or zero as you might expect.  You'll need some 'If NullDate()' logic if you don't want this to appear on the screen.

Hope this helps,
Curt
Try set NullDate() or #1900-01-01# instead of Null
Hello, thanks for the suggestion. I tried the suggestion of if null which sounded solid. I put an IF in Null Vaue expression like so...
If (TestDBTable.List.Current.TestDB.DateField = NullDate(),CurrDate(),#1900-01-01#)
But anything I put in is ignored and 1900-01-01 is entered. So is the documentation wrong? It says to use Null Value:You should use this property when you want to use a null value different from the one provided by Service Studio. 
http://www.outsystems.com/help/servicestudio/5.0/default.htm#Web_User_Interface/Web_Input_Widget_Properties.htm
But it doesnt do this, if i set Null Value to CurrDate() it continues to insert #1900-01-01# .
l cant get Null Value parameter to work as documented?

I have included a project with the IF NullDate suggestion that was made above



IMHO your code is wrong.  If you want the value of null date in the table to be replaced by CurrDate() but if it has a value to preserve that value, your code should be like this.

If (TestDBTable.List.Current.TestDB.DateField = NullDate(), CurrDate(), TestDBTable.List.Current.TestDB.DateField)

Your code inserts #1900-01-01# because in the false condition that's exactly what you are telling it to do.

Hope this helps,
Curt
Hello
?re: Curt Raddatz
Thanks for taking the time to respond. With due respect I dont understand the above statement at all
1: i set my code was:
If (TestDBTable.List.Current.TestDB.DateField = NullDate(), CurrDate(), #1920-02-02#). The above code linne above did say 190001-01 so I understand why you said "exactly what you are telling it to do" but it doesnt matter what I put there , anything entered will come out as 01/01/1900

2: i tried your code above (although i didnt understand why it would work) and it still came out as as 01/01/1900

3: my understanding is the null default will only be triggered if there is a null (if it is not null then the attribute will be ignored. my understanding of the if syntax is:   If ( stmt , true do this , false do this )
Therefore, if the attribute only is triggered for null value, and the if statment is if value is null, then that would mean the 'true' value would be the only condition ever called and the false value will never be called.
As the outsystems does not have a syntax of if (condition , do if true) somethng is added to false just to satisfy the syntax)

As a sanity test if i hard code #1920-02-02# into the null value it still says 1900-01-01

I cannot get Null Value attribute to do anything as i would expect


Hi joseph,

I looked into your oml and i think i have an idea on how to fix this.
After the exectuion of your query in preparation try to assign the value of 
"GetTestDBs.List.Current.TestDB.DateField" to currdate()
Hello.
Nice idea, but for me it still ignores CurrDate() and inserts 01/01/1900.
I can set the date OnSave but then the user doesnt see whats going on.

I think its a bug with the editable table and its just not working?

Hi, I run into this problem also. I would want the date field to display "YYYY-MM-DD" instead of the default 1900-01-01. 

I tried to to assign the date field variable, which is named ContractStart, with this value:

SyntaxEditor Code Snippet

If (ContractStart = NullDate(), "YYYY-MM-DD", ContractStart)


And, it won't allow me:

Date data type required instead of text.


Is there a workaround for this inorder for me to show "YYYY-MM-DD" if the user hasn't chosen a date?





I found the solution:


You need to click on the Date Input Box itself...in this case the -ContractStart


And then set the ff values:


NullValue: NullDate()

Prompt: "YYYY-MM-DD"

Hi Melody,


Instead of setting the value (expecially since it needs do be a date and not a text) you should set the "Prompt" property of the input.

Setting the Prompt in the input to "YYYY-MM-DD" and the Null Value Property to NullDate() does the trick.


See the result here: https://my.outsystemscloud.com/Demos/Dates.aspx


The first input on my screen is just a simple input.
The second one is exactly the same but has a Input_Calendar widget associated.


Regards,
João Rosado

Hehe looks like you found it while I was doing my demo :)

Thank you Joao    That's very helpful