Need end of Month

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Need end of Month

  • Creator
    Topic
  • #52454
    Jerry Tilsley
    Participant

      All,

      Using TCL, what is the best way to obtain what the last day of the current month is?

      Thanks,

      Jerry

    Viewing 6 reply threads
    • Author
      Replies
      • #74259
        Charlie Bursell
        Participant

          First a little proc to get number of days in the month

          proc numberofdays {month year} {

            if {$month==12} {set month 0; incr year}

            clock format [clock scan “[incr month]/1/$year  1 day ago”]

                 -format %d

          }

          Then  get string like

          set dt [clock format [clock seconds] -format “%m %y”]

          lassign $dt month year

          set day [numberofdays $month $year]

          set dayofweek [clock format [clock scan $month/$day/$year] -format %A]

          Lot of code but it works  ðŸ˜€

        • #74260
          Charlie Bursell
          Participant

            First a little proc to get number of days in the month

            proc numberofdays {month year} {

              if {$month==12} {set month 0; incr year}

              clock format [clock scan “[incr month]/1/$year  1 day ago”]

                   -format %d

            }

            Then  get string like

            set dt [clock format [clock seconds] -format “%m %y”]

            lassign $dt month year

            set day [numberofdays $month $year]

            set dayofweek [clock format [clock scan $month/$day/$year] -format %A]

            Lot of code but it works  ðŸ˜€

          • #74261
            Ryan Spires
            Participant

              Think i got it this time…

              set lastDayOfMonth [clock format [clock scan “[clock format [clock scan “1 month”] -format %m/01/%Y] -1 day”] -format %m%d%Y]

              breaking it out:

              set firstDayNextMonth [clock format [clock scan “1 month”] -format %m/01/%Y]

              set lastDayThisMonth [clock format [clock scan “$firstDayNextMonth -1 day”]]

            • #74262
              Jim Kosloskey
              Participant

                Does anyone know if the Tcl Date commands internally compensate for the following:

                “years divisible by 100 aren’t leap years unless they’re a multiple of 400”?

                email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

              • #74263
                Robert Milfajt
                Participant

                  You learn something new every day.  Thanks Jim, I did not know that 4, 100, 400 thing…

                  Robert Milfajt
                  Northwestern Medicine
                  Chicago, IL

                • #74264
                  Jeff Dinsmore
                  Participant

                    Are wondering if you can schedule procedures for 02/29/2100? ;o)

                    My current 8.4 Tcl installation only calculates dates up to 12/31/2037 – on both Linux and Windows.

                    Apparently, Tcl 8.5 does not have this limitation. I don’t have 8.5 installed, but if someone does, it’d be easy to check.

                    clock format [clock scan “02/29/”] -format “%m/%d/%Y”

                    …should return either an error like “can’t convert date” or 03/01/

                    Jeff Dinsmore
                    Chesapeake Regional Healthcare

                  • #74265
                    Scott Folley
                    Participant

                      From what I understand (and I can’t really speak for tcl 8.5 yet) the TCL date commands operate using epoch seconds (seconds since UTC 1 JAN 1970 00:00:00).  In a positive direction this causes it to exceed maxint in a positive direction in 2037.  More alarming and a bigger hassle is the fact that ages of people born before ~1903 exceed maxint in a negative direction.  In healthcare THAT is a calculation and a problem that you WILL be forced to deal with at some point.  ðŸ˜‰

                  Viewing 6 reply threads
                  • The forum ‘Cloverleaf’ is closed to new topics and replies.