23
Views
4
Comments
Converting Text to Date format
Question
Application Type
Reactive

Hello everyone

I have two input fields, one for 'Retest Date' with a text data type, and another for 'Manufacturing Date' with a date data type. My user enters a value of '2 years' in the 'Retest Date' field and a manufacturing date of '27-08-2024' in the 'Manufacturing Date' field. I need to calculate the date that is 2 years from the entered manufacturing date and display it in the 'New Retest Date' field. How can I achieve this?"


2024-05-06 07-41-12
Narendra Tiwari

Hi Male,

you can just use the following function

AddYears((Yourmanufacture Date Variable),TextToInteger(retest variable))

this should solve your problem.
Thanks 
Narendra Tiwari



2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Male,

If it's really free text you are allowing in the "retest date" field, you need to write a parser for that. And that's not something I'd advise you, and neither is it specific to OutSystems.

2024-03-23 18-16-49
Bryan Villalobos

Hi @Male Navitha ,

In addition to what Killian have already pointed out, I would suggest that you change the free text into something else, probably an integer field with label "Retest Date (in years)" or months or days depending on the usual frequency. You can even customize it depending on the requirements. Allowing it to be free text means they can input anything, even "2 decades", or maybe even "2 fortnights, 7 and a half days, 13.56 hours". Creating a parser for that will be quite a headache. 

So it would really be very easy if you would make it more simple. If your input is just integer, then you'll just have to use AddYears(ManufacturingDate, RetestDate) and assign it to your New Retest Date field.

There are other simple ways as well to do this and I hope you don't sweat too much on making it complicated. 


Regards,

Bryan

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.