Page 1 of 1

YYYYMMDD -> DDMMYYYY field for the web

Posted: Thu Nov 22, 2018 9:40 pm
by sotos
Hello,

is there any straight forward way from YYYYMMDD to DDMMYYYY field for the web as in "Use Builtin(FINDDATE) With_Args..." ?

best,
Sotiris

Re: YYYYMMDD -> DDMMYYYY field for the web

Posted: Thu Nov 22, 2018 11:41 pm
by dominique
Hi Sotiris

Did you try something like this

Define Field(#InputDate) Type(*Dec) Length(8) Decimals(0)
Define Field(#OutputDate) Type(*Dec) Length(8) Decimals(0)

#InputDate := *YYYYMMDD
#OutputDate := #InputDate.AsDate( CCYYMMDD ).AsNumber( DDMMCCYY )


Dominique

Re: YYYYMMDD -> DDMMYYYY field for the web

Posted: Fri Nov 23, 2018 6:07 pm
by sotos
Hi,

thanks,

I tried the following and worked:

#Date := #YYYYMMDD.AsString
#DDMMYYYY := (#Date.Substring( 7 2 ) + #Date.Substring( 5 2 ) + #Date.Substring( 1 4 )).AsNumber

but your solution seems much more efficient.

Sotiris

Re: YYYYMMDD -> DDMMYYYY field for the web

Posted: Mon Nov 26, 2018 11:29 am
by Dominik
Hi Sotiris

Just to add to Dominique's response, it is a good idea to make sure that the entered date is a valid one, before executing the AsDate intrinsic function - otherwise you will get a runtime error with that code

If ( #InputDate.IsDate( CCYYMMDDD ) )
#OutputDate := #InputDate.AsDate( CCYYMMDD ).AsNumber( DDMMCCYY )
Else
* Handle the input error
Endif