Loading ...
Sorry, an error occurred while loading the content.
 

Re: [Clip] Entering a different date

Expand Messages
  • John Zeman
    ... Here ya go mate. I can t take credit for this clip however, the main engine that parses the date you enter was written by Steve Veltkamp several years
    Message 1 of 9 , Aug 4, 2006
      --- In ntb-clips@yahoogroups.com, Lee Underwood <leeu@...> wrote:
      >
      > I just basically need a clip that asks
      > "What will the date be?" and then format it into
      > the three different formats. It doesn't need to
      > be run more than once during a session.
      >
      > Lee
      >
      >



      Here ya go mate. I can't take credit for this clip however, the main
      engine that parses the date you enter was written by Steve Veltkamp
      several years ago. To this day I use it all the time for needs such
      as yours.

      You should be able to adapt it to the format you need.

      John



      ;begin clip to insert any date in long form

      ^!Set %indtg%=^?{(M="00/00/0000;1;*")Enter Date (mm/dd/yyyy)}
      ^!Set %y%=^$StrCopy(^%indtg%;7;4)$
      ^!Set %m%=^$StrCopy(^%indtg%;1;2)$
      ^!Set %d%=^$StrCopy(^%indtg%;4;2)$

      ^!If ^%m%<3 z1
      :z
      ^!Set %z%=^%y%
      ^!Goto calc
      :z1
      ^!Set %z%=^$CALC(^%y%-1)$
      :calc
      ^!Set %z4%=^$CALC(^%z%/4;3)$
      ^!Set %iz4%=^$CALC(INT(^%z4%))$
      ^!Set %z100%=^$CALC(^%z%/100;3)$
      ^!Set %iz100%=^$CALC(INT(^%z100%))$
      ^!Set %z400%=^$CALC(^%z%/400;3)$
      ^!Set %iz400%=^$CALC(INT(^%z400%))$
      ^!Set %m23%=^$CALC(^%m%*23)$
      ^!Set %m9%=^$CALC(^%m23%/9;3)$
      ^!Set %im9%=^$CALC(INT(^%m9%))$
      ^!If ^%m%<3 DOW1
      :DOW
      ^!Set %dow%=^$CALC(^%im9%+^%d%+4+^%z%+^%iz4%-^%iz100%+^%iz400%-2)$
      ^!Set %day%=^$CALC(^%dow%MOD7)$
      ^!Goto Weekday
      :DOW1
      ^!Set %dow%=^$CALC(^%im9%+^%d%+4+^%z%+^%iz4%-^%iz100%+^%iz400%+1)$
      ^!Set %day%=^$CALC(^%dow%MOD7)$
      ^!if ^%m%=01 ^!Set %month%="January"
      ^!if ^%m%=02 ^!Set %month%="February"
      ^!if ^%m%=03 ^!Set %month%="March"
      ^!if ^%m%=04 ^!Set %month%="April"
      ^!if ^%m%=05 ^!Set %month%="May"
      ^!if ^%m%=06 ^!Set %month%="June"
      ^!if ^%m%=07 ^!Set %month%="July"
      ^!if ^%m%=08 ^!Set %month%="August"
      ^!if ^%m%=09 ^!Set %month%="September"
      ^!if ^%m%=10 ^!Set %month%="October"
      ^!if ^%m%=11 ^!Set %month%="November"
      ^!if ^%m%=12 ^!Set %month%="December"
      :Weekday
      ^!if ^%m%=01 ^!Set %month%="January"
      ^!if ^%m%=02 ^!Set %month%="February"
      ^!if ^%m%=03 ^!Set %month%="March"
      ^!if ^%m%=04 ^!Set %month%="April"
      ^!if ^%m%=05 ^!Set %month%="May"
      ^!if ^%m%=06 ^!Set %month%="June"
      ^!if ^%m%=07 ^!Set %month%="July"
      ^!if ^%m%=08 ^!Set %month%="August"
      ^!if ^%m%=09 ^!Set %month%="September"
      ^!if ^%m%=10 ^!Set %month%="October"
      ^!if ^%m%=11 ^!Set %month%="November"
      ^!if ^%m%=12 ^!Set %month%="December"
      ^!if ^%day%=0 ^!Set %day%="Sunday"
      ^!if ^%day%=1 ^!Set %day%="Monday"
      ^!if ^%day%=2 ^!Set %day%="Tuesday"
      ^!if ^%day%=3 ^!Set %day%="Wednesday"
      ^!if ^%day%=4 ^!Set %day%="Thursday"
      ^!if ^%day%=5 ^!Set %day%="Friday"
      ^!if ^%day%=6 ^!Set %day%="Saturday"


      ^!InsertText ^%day%, ^%month% ^%d%, ^%y%
    • abairheart
      Hmm, instead of all the if statements, why not have arrays for these case, i.e. ^!SetArray %dayofweek%=Sunday;Monday;... ^!SetArray
      Message 2 of 9 , Aug 6, 2006
        Hmm, instead of all the if statements, why not have arrays
        for these case, i.e.

        ^!SetArray %dayofweek%=Sunday;Monday;...
        ^!SetArray %monthname%=January;February;...


        When you need to extract the day of week, increment the index:
        ^!Inc %day%
        ^!Set %day%=^%dayofweek^%day%%

        For months, you will not have to increment:
        ^!Set %month%=^%monthname^%month%%



        Abair.



        --- In ntb-clips@yahoogroups.com, "John Zeman" <john041650@...> wrote:
        >
        > --- In ntb-clips@yahoogroups.com, Lee Underwood <leeu@> wrote:
        >
        >
        > ;begin clip to insert any date in long form
        >
        > ^!Set %indtg%=^?{(M="00/00/0000;1;*")Enter Date (mm/dd/yyyy)}
        > ^!Set %y%=^$StrCopy(^%indtg%;7;4)$
        > ^!Set %m%=^$StrCopy(^%indtg%;1;2)$
        > ^!Set %d%=^$StrCopy(^%indtg%;4;2)$
        >
        > ^!If ^%m%<3 z1
        > :z
        > ^!Set %z%=^%y%
        > ^!Goto calc
        > :z1
        > ^!Set %z%=^$CALC(^%y%-1)$
        > :calc
        > ^!Set %z4%=^$CALC(^%z%/4;3)$
        > ^!Set %iz4%=^$CALC(INT(^%z4%))$
        > ^!Set %z100%=^$CALC(^%z%/100;3)$
        > ^!Set %iz100%=^$CALC(INT(^%z100%))$
        > ^!Set %z400%=^$CALC(^%z%/400;3)$
        > ^!Set %iz400%=^$CALC(INT(^%z400%))$
        > ^!Set %m23%=^$CALC(^%m%*23)$
        > ^!Set %m9%=^$CALC(^%m23%/9;3)$
        > ^!Set %im9%=^$CALC(INT(^%m9%))$
        > ^!If ^%m%<3 DOW1
        > :DOW
        > ^!Set %dow%=^$CALC(^%im9%+^%d%+4+^%z%+^%iz4%-^%iz100%+^%iz400%-2)$
        > ^!Set %day%=^$CALC(^%dow%MOD7)$
        > ^!Goto Weekday
        > :DOW1
        > ^!Set %dow%=^$CALC(^%im9%+^%d%+4+^%z%+^%iz4%-^%iz100%+^%iz400%+1)$
        > ^!Set %day%=^$CALC(^%dow%MOD7)$
        > ^!if ^%m%=01 ^!Set %month%="January"
        > ^!if ^%m%=02 ^!Set %month%="February"
        > ^!if ^%m%=03 ^!Set %month%="March"
        > ^!if ^%m%=04 ^!Set %month%="April"
        > ^!if ^%m%=05 ^!Set %month%="May"
        > ^!if ^%m%=06 ^!Set %month%="June"
        > ^!if ^%m%=07 ^!Set %month%="July"
        > ^!if ^%m%=08 ^!Set %month%="August"
        > ^!if ^%m%=09 ^!Set %month%="September"
        > ^!if ^%m%=10 ^!Set %month%="October"
        > ^!if ^%m%=11 ^!Set %month%="November"
        > ^!if ^%m%=12 ^!Set %month%="December"
        > :Weekday
        > ^!if ^%m%=01 ^!Set %month%="January"
        > ^!if ^%m%=02 ^!Set %month%="February"
        > ^!if ^%m%=03 ^!Set %month%="March"
        > ^!if ^%m%=04 ^!Set %month%="April"
        > ^!if ^%m%=05 ^!Set %month%="May"
        > ^!if ^%m%=06 ^!Set %month%="June"
        > ^!if ^%m%=07 ^!Set %month%="July"
        > ^!if ^%m%=08 ^!Set %month%="August"
        > ^!if ^%m%=09 ^!Set %month%="September"
        > ^!if ^%m%=10 ^!Set %month%="October"
        > ^!if ^%m%=11 ^!Set %month%="November"
        > ^!if ^%m%=12 ^!Set %month%="December"
        > ^!if ^%day%=0 ^!Set %day%="Sunday"
        > ^!if ^%day%=1 ^!Set %day%="Monday"
        > ^!if ^%day%=2 ^!Set %day%="Tuesday"
        > ^!if ^%day%=3 ^!Set %day%="Wednesday"
        > ^!if ^%day%=4 ^!Set %day%="Thursday"
        > ^!if ^%day%=5 ^!Set %day%="Friday"
        > ^!if ^%day%=6 ^!Set %day%="Saturday"
        >
        >
        > ^!InsertText ^%day%, ^%month% ^%d%, ^%y%
        >
      • Lee Underwood
        John, Sorry for taking so long to get back ... just real busy. That s the answer I was looking for! Thanks. I also learned a bit from it. Lee On 8/4/2006 08:31
        Message 3 of 9 , Aug 21, 2006
          John,

          Sorry for taking so long to get back ... just real busy.

          That's the answer I was looking for! Thanks. I also learned a bit from it.

          Lee


          On 8/4/2006 08:31 PM, John Zeman wrote:
          ........................................................

          >Here ya go mate. I can't take credit for this clip however, the
          >main engine that parses the date you enter was written by Steve
          >Veltkamp several years ago. To this day I use it all the time for
          >needs such as yours.
          >
          >You should be able to adapt it to the format you need.
          >
          >John
          >
          >;begin clip to insert any date in long form
          >
          >^!Set %indtg%=^?{(M="00/00/0000;1;*")Enter Date (mm/dd/yyyy)}
          >^!Set %y%=^$StrCopy(^%indtg%;7;4)$
          >^!Set %m%=^$StrCopy(^%indtg%;1;2)$
          >^!Set %d%=^$StrCopy(^%indtg%;4;2)$
          >
          >^!If ^%m%<3 z1
          >:z
          >^!Set %z%=^%y%
          >^!Goto calc
          >:z1
          >^!Set %z%=^$CALC(^%y%-1)$
          >:calc
          >^!Set %z4%=^$CALC(^%z%/4;3)$
          >^!Set %iz4%=^$CALC(INT(^%z4%))$
          >^!Set %z100%=^$CALC(^%z%/100;3)$
          >^!Set %iz100%=^$CALC(INT(^%z100%))$
          >^!Set %z400%=^$CALC(^%z%/400;3)$
          >^!Set %iz400%=^$CALC(INT(^%z400%))$
          >^!Set %m23%=^$CALC(^%m%*23)$
          >^!Set %m9%=^$CALC(^%m23%/9;3)$
          >^!Set %im9%=^$CALC(INT(^%m9%))$
          >^!If ^%m%<3 DOW1
          >:DOW
          >^!Set %dow%=^$CALC(^%im9%+^%d%+4+^%z%+^%iz4%-^%iz100%+^%iz400%-2)$
          >^!Set %day%=^$CALC(^%dow%MOD7)$
          >^!Goto Weekday
          >:DOW1
          >^!Set %dow%=^$CALC(^%im9%+^%d%+4+^%z%+^%iz4%-^%iz100%+^%iz400%+1)$
          >^!Set %day%=^$CALC(^%dow%MOD7)$
          >^!if ^%m%=01 ^!Set %month%="January"
          >^!if ^%m%=02 ^!Set %month%="February"
          >^!if ^%m%=03 ^!Set %month%="March"
          >^!if ^%m%=04 ^!Set %month%="April"
          >^!if ^%m%=05 ^!Set %month%="May"
          >^!if ^%m%=06 ^!Set %month%="June"
          >^!if ^%m%=07 ^!Set %month%="July"
          >^!if ^%m%=08 ^!Set %month%="August"
          >^!if ^%m%=09 ^!Set %month%="September"
          >^!if ^%m%=10 ^!Set %month%="October"
          >^!if ^%m%=11 ^!Set %month%="November"
          >^!if ^%m%=12 ^!Set %month%="December"
          >:Weekday
          >^!if ^%m%=01 ^!Set %month%="January"
          >^!if ^%m%=02 ^!Set %month%="February"
          >^!if ^%m%=03 ^!Set %month%="March"
          >^!if ^%m%=04 ^!Set %month%="April"
          >^!if ^%m%=05 ^!Set %month%="May"
          >^!if ^%m%=06 ^!Set %month%="June"
          >^!if ^%m%=07 ^!Set %month%="July"
          >^!if ^%m%=08 ^!Set %month%="August"
          >^!if ^%m%=09 ^!Set %month%="September"
          >^!if ^%m%=10 ^!Set %month%="October"
          >^!if ^%m%=11 ^!Set %month%="November"
          >^!if ^%m%=12 ^!Set %month%="December"
          >^!if ^%day%=0 ^!Set %day%="Sunday"
          >^!if ^%day%=1 ^!Set %day%="Monday"
          >^!if ^%day%=2 ^!Set %day%="Tuesday"
          >^!if ^%day%=3 ^!Set %day%="Wednesday"
          >^!if ^%day%=4 ^!Set %day%="Thursday"
          >^!if ^%day%=5 ^!Set %day%="Friday"
          >^!if ^%day%=6 ^!Set %day%="Saturday"
          >
          >
          >^!InsertText ^%day%, ^%month% ^%d%, ^%y%
          ........................................................
        Your message has been successfully submitted and would be delivered to recipients shortly.