YYYYMMDD -> DDMMYYYY field for the web

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
sotos
Posts: 31
Joined: Fri Feb 09, 2018 11:25 pm

YYYYMMDD -> DDMMYYYY field for the web

Post 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
dominique
Posts: 50
Joined: Mon May 29, 2017 4:16 pm
Location: St. Gallen, Switzerland

Re: YYYYMMDD -> DDMMYYYY field for the web

Post 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
sotos
Posts: 31
Joined: Fri Feb 09, 2018 11:25 pm

Re: YYYYMMDD -> DDMMYYYY field for the web

Post 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
Dominik
Posts: 21
Joined: Fri Jun 10, 2016 12:14 pm

Re: YYYYMMDD -> DDMMYYYY field for the web

Post 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
Post Reply