Plex 2E

Expand all | Collapse all

Getting the system date and time in 2E

  • 1.  Getting the system date and time in 2E

    Posted Aug 11, 2015 03:17 PM

    Does anyone know if there a simple way to get the system date and time in synon?  I cannot use the Job Date since it pulls yesterday's date after midnight.  I have a date and time field in the following formats, yyyymmdd and HHMMSS respectively.  I thought of doing substring on the system timestamp but I'm hoping there is a better solution.

     

    Ken



  • 2.  Re: Getting the system date and time in 2E

    Posted Aug 11, 2015 03:37 PM

    Hi Ken,

    Yes, you can use the JOB context, along with the field "*System Timestamp" to get the current date and time.

     

    I hope that helps!

    Regards,

    Jill Hitz

    CA Support



  • 3.  Re: Getting the system date and time in 2E

    Posted Aug 11, 2015 03:44 PM

    Unfortunately, that does not work, get message: *System timestamp' & 'TL Date Out' have unmatching field types.  but it does let me use JOB with Job Date.  Wish there was a JOB System Date and Job System Time.

     

    Thanks,

     

    Ken



  • 4.  Re: Getting the system date and time in 2E

    Posted Aug 13, 2015 10:31 AM

    What type of field is your 'TL Date Out'?

    The left hand side of a *MOVE where the right hand side is JOB.*System timestamp or any TS# field can be any valid date or time field: DTE, D8#, DT#, TME or TM# and of course TS#.

    See the Building Applications manual: Considerations for Date and Time Field Types.



  • 5.  Re: Getting the system date and time in 2E

    Posted Aug 13, 2015 11:20 AM

    If you search your Action Diagram for Errors, then using DTE and D8# with JOB.*System timestamp will produce error Y2V6314 Incompatible data types. 

    These are spurious error messages that can safely be ignored: it will work fine!



  • 6.  Re: Getting the system date and time in 2E

    Posted Aug 13, 2015 11:50 AM

    Where do you see errors ? I use DTE in every one of my programs. That the first line of code for me is get the date & time.

     

     

    WRK.*Job date = JOB.*System timestamp     

    WRK.*Job time = JOB.*System timestamp 



  • 7.  Re: Getting the system date and time in 2E

    Posted Aug 13, 2015 12:58 PM

    The main issue now is the field is 8 pos and nbr not date.



  • 8.  Re: Getting the system date and time in 2E

    Posted Aug 13, 2015 01:50 PM

    It is also possible to do a basic move of JOB.*System timestamp to any date or time field.  You can not simply pass it as a parameter.  With the move statement, Synon will correctly parse the current system timestamp value based on the data type of the target variable.  It works in both RPG and RPGLE.

     

    DTE 7.0 – decimal CYYMMDD

    D8# 8.0 – decimal YYYYMMDD

    DT# 10 – ISO ‘YYYY-MM-DD’

     

    TME 6.0 – decimal HHMMSS

    TM# 8 – ISO ‘HH.MM.SS’

     

    SynonTimestamp.jpg

     

    ~David



  • 9.  Re: Getting the system date and time in 2E

    Posted Aug 14, 2015 03:59 AM

    See the manual section Considerations for Date and Time Field Types.

    You will need to use an intermediate date field and then move this to your number



  • 10.  Re: Getting the system date and time in 2E

    Posted Aug 14, 2015 04:00 AM

    See the manual section Considerations for Date and Time Field Types.

    You could use an intermediate date field then move that to your number field



  • 11.  Re: Getting the system date and time in 2E

    Posted Aug 11, 2015 04:27 PM

    WRK.*Job date = JOB.*System timestamp     

    WRK.*Job time = JOB.*System timestamp     

     

    *Job date                 DTE           7.0  *JOBDTE        ATR

    *Job time                 TME           6.0  *JOBTME        ATR

    *System timestamp    TS#          26    *TIMESTAMP     ATR

     

    works for me



  • 12.  Re: Getting the system date and time in 2E

    Posted Aug 11, 2015 04:56 PM

    Thanks John, that works then I have to add 19000000 for my 8 pos date field.  Still wish they have a JOB  System Date selection.

     

    Thanks,

     

    Ken



  • 13.  Re: Getting the system date and time in 2E

    Posted Aug 12, 2015 04:14 AM

    Dates..

    Just how many ways are there to fool with dates?

     

    Don't answer that - its a big number.

     

    Nowadays - with faster processors and timestamps needing more precision, I've gone to a line of RPGLE user source contained in a function called 'Timestamp accurately'

     

    Here's the USRSRC - and, yes, its using a WRK context

     

    **  provide an updated timestamp                                                            

    D  Zztimestamp    S               z                                        ; timestamp       

    ** /\/\/                                                                                    

    C** /\/\/                                                                                    

    **  provide an updated timestamp                                                            

    C**   user source to generate accurate timestamp                                             

    C                   Time                    Zztimestamp                                      

    C                   MOVE      zztimestamp   wuagts                         ; into WRK context

    C**                                                                                          

    **  provide an updated timestamp                                                            

    C** /\/\/                                                                                   

     

     

    and that USRSRC is embedded in this INTFUN - using the WRK variable nails the field name in place.  I could have used #I and #O direct to the the usrsrc, but didn't - can't remember why not now - probably something to do with the function it first went into.

     

     

    > Timestamp accurately                                            

    .--                                                               

    . /**  intfun start                                               

    . **  Jan 2004 - included usrsrc to run %timestamp                

    . **  fix the field name by using WRK for the code line           

    . WRK.Timestamp = LCL.Timestamp                                   

    . time opcode to par - #Utilities  *                            <<-----  this is the USRSRC   

    . PAR.Timestamp = WRK.Timestamp                                   

    . /**  intfun end                                                 

    '--                                                              

     

     

    I see I have quite a range of functions for decomposing timestamps, comparing them, and so on.

    equally, I now have a single function for date format conversion -  'all known date formats' are parameters, and when it is called with just 1 value, it returns all other fields in converted form.

    so something like this

     

    Clear all date fields

    Get current timestamp

    extract date from timestamp

    convert date to 'all known formats'

     

    place required date (and time?)  wherever its needed

     

     

    Richard Wilson