Hello,
I have to transfer data into IBMi database files that contain datetime fields in unix timestamp format.
E.g.: datetime field = 1478069006 - has to be converted into date = 02/11/2016 and time = 07:43:26
How can this be done easily with LANSA? Are there any intrinsic functions or BIFs for this?
Best regards,
Joerg
Unix Timestamp
- Stewart Marshall
- Posts: 417
- Joined: Thu Nov 05, 2015 5:25 pm
Re: Unix Timestamp
Hi Joerg
There's nothing specific in RDMLX to help with this, but the conversion isn't too tricky
Begin_Com Role(*EXTENDS #PRIM_WEB) Height(441) Width(929)
Define_Com Class(#prim_spdt) Name(#Seconds) DisplayPosition(1) Left(24) Parent(#COM_OWNER) TabPosition(1) Top(15) Height(26)
Define_Com Class(#xDemoDateTime.Visual) Name(#xDemoDateTime) DisplayPosition(2) Left(24) Parent(#COM_OWNER) TabPosition(2) Top(48) Height(25)
There's nothing specific in RDMLX to help with this, but the conversion isn't too tricky
Begin_Com Role(*EXTENDS #PRIM_WEB) Height(441) Width(929)
Define_Com Class(#prim_spdt) Name(#Seconds) DisplayPosition(1) Left(24) Parent(#COM_OWNER) TabPosition(1) Top(15) Height(26)
Define_Com Class(#xDemoDateTime.Visual) Name(#xDemoDateTime) DisplayPosition(2) Left(24) Parent(#COM_OWNER) TabPosition(2) Top(48) Height(25)
Code: Select all
Evtroutine Handling(#Com_owner.CreateInstance)
#xDemoDateTime := "2016-11-02 07:43:26"
#Seconds := (#xDemoDateTime.Date.Difference( 1970-01-01 ) * 86400) + #xDemoDateTime.AsSeconds
Endroutine
Evtroutine Handling(#xDemoDateTime.Changed)
#Seconds := (#xDemoDateTime.Date.Difference( 1970-01-01 ) * 86400) + #xDemoDateTime.AsSeconds
Endroutine
Evtroutine Handling(#Seconds.Changed)
Define_Com Class(#Prim_nmbr) Name(#Days)
Define_Com Class(#Prim_nmbr) Name(#RemainingSeconds)
Define_Com Class(#Prim_nmbr) Name(#SecondsUntilMidnigth)
Define_Com Class(#Prim_time) Name(#SecondsAsaTime)
#Days := #Seconds / 86400
#RemainingSeconds := #Seconds - (#Days * 86400)
#SecondsAsaTime := #SecondsAsaTime.Adjust( #RemainingSeconds )
#xDemoDateTime := ("19700101").AsDate( CCYYMMDD ).Adjust( (#Seconds / 86400) )
#xDemoDateTime := ((#xDemoDateTime.Date.AsDisplayString( CCYYMMDD ) + #SecondsAsaTime.AsDisplayString( HHMMSS ))).AsDateTime( CCYYMMDDHHMMSS )
Endroutine
End_Com-
Joerg Hamacher
- Posts: 124
- Joined: Thu Feb 11, 2016 12:01 am
Re: Unix Timestamp
Hello Stewart,
this is great! Thank you!
Have a nice time,
Joerg
this is great! Thank you!
Have a nice time,
Joerg