Hi,

In  my mobile application,i want to convert text to date but it returns "0". So i used NewDate() function with the help of substring. But my input like "1/3/2019" if suppose the input change as "22/12/2019" it got varies and the output is wrong. And I have used other method(String_Split) instead of substring but it returns "01" it doesnt returns like "1 3 2019 ".


Can anyone suggest for this problem?

When using TextToDate you must ensure that the date complies with the default date formats (yyyy-mm-dd, yyyy/mm/dd, or yyyy.mm.dd) or the server’s environment configuration.

I'm assuming you don't want to change the environment configuration, so you have to find a custom date importer. This one does what you need.


Btw, the split returns a list. Are you sure that 1 wasn't just the first element?


Nuno Reis wrote:

When using TextToDate you must ensure that the date complies with the default date formats (yyyy-mm-dd, yyyy/mm/dd, or yyyy.mm.dd) or the server’s environment configuration.

I'm assuming you don't want to change the environment configuration, so you have to find a custom date importer. This one does what you need.


Btw, the split returns a list. Are you sure that 1 wasn't just the first element?


I am giving like "1/3/1991" not as "1991/3/1". 


Have you tried the component I linked?

Nuno Reis wrote:

Have you tried the component I linked?

Yeah i tried, but it doesnt work. it returns as "1900-01-01"


Are you sure the date is valid? Those three ways are the default way of converting. TextToDate is excluded because of the format, but TextUtils function should do the trick with most date formats and Split always works.

Nuno Reis wrote:

Are you sure the date is valid? Those three ways are the default way of converting. TextToDate is excluded because of the format, but TextUtils function should do the trick with most date formats and Split always works.

I am sure about that.


Try to use FormatDateTime() Function to format the date as you want.


I Hope it will helps you!


Thanks and Best Regards,

Nuno Pereira

Nuno Reis wrote:

When using TextToDate you must ensure that the date complies with the default date formats (yyyy-mm-dd, yyyy/mm/dd, or yyyy.mm.dd) or the server’s environment configuration.

I'm assuming you don't want to change the environment configuration, so you have to find a custom date importer. This one does what you need.


Btw, the split returns a list. Are you sure that 1 wasn't just the first element?


Hi @Nuno Reis,

To use TextToDate, you do not necessarily have to be in that order yyyy-mm-dd.
Just be a valid date that the function will work perfectly.


Regards

Eduardo


Eduardo Benites wrote:

Hi @Nuno Reis,

To use TextToDate, you do not necessarily have to be in that order yyyy-mm-dd.
Just be a valid date that the function will work perfectly.


Regards

Eduardo


I copied it from the data conversion documentation.


@Nuno Gonçalo Pereira

The question is about TextToDate, not DateToText.


okay, sorry my bad. 

I couldn't understand the problem.