ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

getting last weeks monday to Friday Dates

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

  • getting last weeks monday to Friday Dates

    Just for info....

    Code:
         d dayofweek       s              1  0
         d fromMonday      s              6  0
         d monday          s               d
         d toFriday        s              6  0
    
                  //this junk gives you last weeks Monday to Friday dates in MMDDYY
                  //this should work till arounf 2012 when the world explodes
                  //day of week 1=Sun 2=Monday ......7=Sat
    
          /free
                    dayofweek = %rem(%diff(%date():D'1899-12-30':*days):7);
                    if dayofweek < 1;
                     dayofweek += 7;
                    endif;
                    // need to get to current weeks Monday
                    if dayofweek = 1;
                     monday = %date() + %days(1);
                    else;
                     monday = %date() - %days(dayofweek-2);
                    endif;
    
                    fromMonday = %dec(monday - %days(7):*mdy);
                    toFriday = %dec(monday - %days(3):*mdy);
    
                    *inlr = *on;
          /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

  • #2
    Re: getting last weeks monday to Friday Dates

    Quote from the German forum today:
    Code:
    /free 
    EXEC SQL 
    Set : DayName = DAYNAME(: Date); 
    return DayName; 
    /end-free
    Reply from Birgitta, (hopefully I translated correctly):
    Rather use the SQL functions : DayOfWeek or DayOfWeek_ISO.

    DayOfWeek starts with Sunday, i.e. Sun.=1 und Sat. = 7.
    DayOfWeek_ISO starts with Monday, i.e. Mon.=1 und Sun = 7.
    Regards

    Kit
    http://www.ecofitonline.com
    DeskfIT - ChangefIT - XrefIT
    ___________________________________
    There are only 3 kinds of people -
    Those that can count and those that can't.

    Comment


    • #3
      Re: getting last weeks monday to Friday Dates

      I was gonna post that... she has actually posted that a couple of times here..

      But just in case you dont have SQL

      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


      • #4
        Re: getting last weeks monday to Friday Dates

        Originally posted by jamief View Post
        But just in case you dont have SQL
        That's not funny... for 2 months, we didn't have SQL on our test box. 'twas no fun

        At that time (2 years ago) we went through 4 test boxes in 2 years

        and we have a problem at the moment again, some files are corrupted... and that after re-initializing the disks (i.e. format c: ) just 2 weeks ago.
        Regards

        Kit
        http://www.ecofitonline.com
        DeskfIT - ChangefIT - XrefIT
        ___________________________________
        There are only 3 kinds of people -
        Those that can count and those that can't.

        Comment


        • #5
          Re: getting last weeks monday to Friday Dates

          Move all programs including chagefit to UBUNTU
          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

          Working...
          X