lotus-noteslotus-dominolotusscriptlotuslotus-formula

Lotus Notes data saved as text field convert to date/time


Old form that will be replaced by a New, and add a new view.

Old form has:

Expiration Date = Text field

New form:

Expiration Date = Date/Time field

View contains Exp. Date and Days Left. Problem is Expiration Date of existing data is saved as a Text field. Days Left column read the Exp. Date as a text instead of Date/Time field. So the Days Left column's output is:

ERROR: Incorrect data type for operator or @Function

Is there a way to convert all the existing date's field to date/time instead of text so the Days Left column's info will be correct? except to re-input the dates manually because the data are too many.


Solution

  • Just create a formula agent with one line of code:

    FIELD ExpirationDate := @TextToTime( ExpirationDate )
    

    And let it run on all documents that contain fields with the wrong type.

    Of course you could do some error handling in your code as well as:

    _newVal := @TextToTime( ExpirationDate );
    
    FIELD ExpirationDate := @If( @IsError( _newVal ); SomeFallbackValue ; _newVal )