ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Date timestamp error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Date timestamp error

    I got a physical file with a date type field. Iam trying to input the data for that field. I have declared a decimal field on screen for it, with length 8. And I have written one RPGLE program for writing that data to file. For this I've used two data structures. One to store the screen data and the second one to convert it to the physical file date format i.e. 'YYYY-MM-DD'.
    The second data structure contains splitted fields to get the above format. Here Iam getting the run time error i.e. 'Date Timestamp error'.
    Is there any way to rectify this problem?

  • #2
    Re: Date timestamp error

    No neee to use Data structures

    Use the following code

    filefielddate = %Date(Displayfiledate:*ISO);

    this need not be *ISO. this tells the date format of ur display file numeric field.
    Thanks,
    Giri

    Comment


    • #3
      Re: Date timestamp error

      Please dont use datastructures to convert your dates....

      what version of the opperating system on you on?

      Code:
      d CCYYMMDD        s              9  0             
      d ISODate         s               D               
                                                        
       /free                                            
        eval  Isodate = %Date();                        
        CCYYMMDD = %Int( %Char( Isodate : *ISO0 ) );    
        DSPLY   %char(CCYYMMDD);                        
        eval *INlr = *On;                               
       /end-free
      Code:
        H DftActGrp(*No) Option(*SrcStmt : *NoDebugIO)             
       * Convert 033104 to 20040331                              
      d dateMDY         S            006  0 inz(033104)          
      d Isodate         S               D                        
      d dateCYMD        S            008  0                      
      d reply           S            001                         
      d chr8            S            008                         
      c     *MDY          test(de)                DateMDY        
      c                   if        not%Error                    
      c     *MDY          move      DateMDY       Isodate        
      c                   move      Isodate       dateCYMD       
      c                   move      dateCYMD      Chr8           
      c     Chr8          dsply     reply                        
      c                   endif                                  
      c                   eval      *inlr = *On

      Code:
      	 V5R1
      	
      	  H bnddir('QC2LE')   
      	  D atoll           pr            20i 0 extproc('atoll')   
      	  D  string                         *   value options(*string)
      	  
      	  /free 
      	  numDate = atoll(%char(date : *eur0));
                       /End Free

      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: Date timestamp error

        I have declared a decimal field on screen for it
        Why? You can define a date field in the DDS. You don't need to convert and it also won't let you enter an invalid date.
        Life is a constant struggle against maturity

        Comment


        • #5
          Re: Date timestamp error

          Thanks replying.
          When using the file field reference how can I declare date field on screen?
          Incase in file if the date field is declared in default format i.e. (YYYY-MM-DD), how this field can be displayed on screen, when I used the file field reference.

          Even I tried to display the file field on screen, using file reference, but while inputting the value 'Date Time Invalid' error is coming.

          And Iam using V5R1. Please suggest me the date handling both in RPG and RPGLE

          Comment


          • #6
            Re: Date timestamp error

            Are you asking how to display ( 0001-01-01)
            just check to see if the date field = *loval
            before you move to field on display if it is *loval
            then do something else with it.

            jamie
            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment


            • #7
              Re: Date timestamp error

              Hi

              If editing *LOVAL date is problem, then search for MAPVAL keyword in *DSPF.
              I posted this answer on forum sometimes ago.

              Last edited by Zdenko; March 8, 2006, 06:42 AM.
              LP Zdenko

              Comment

              Working...
              X