Puting a zero on to a date

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Puting a zero on to a date

  • Creator
    Topic
  • #47904
    Jodi Agosta2
    Participant

    Ok I know this should be easy but I can not seem to make this work. I am getting the date in two fields Century and date. Because the way that the date field is set up it is 8 long but contains only 6 numbers. The rest is spaces [ ex bb990305 where b is a blank] I grab this and format it, concat it with the century and it looks great until I get this : bbb50307. I have tried regsub and a host of other tcl comands to change that blank into a zero but it just isn’t working. I keep getting 20 50307. What am I doing wrong?

    Thanks in Advance,

    Jodi

Viewing 1 reply thread
  • Author
    Replies
    • #57035
      Charlie Bursell
      Participant

      try this

      set dt ”   50307″

      # Adjust date to make it 6 bytes RJZF

      # Note I use “s” here just in case of not all digits

      set dt [format “%06s” [string trimleft $dt]]

      # Assume century of 20

      set century 20

      # If year greater than 50 (or some value) make century 19

      if {[string trimleft [string range $dt 0 1] 0] > 50} {set century 19}

      # Now just append them

      set newdate $century$dt

    • #57036
      Jodi Agosta2
      Participant

      Hi Charlie

      Here is what I came up with using your suggestion:

      set xlatetemp [lrange $xlateInVals 0 0]

      set xlatetemp [format %06s [string trimleft $xlatetemp]]

      set xlateOutVals $xlatetemp

      See my mistake…I was bringing it in with a lrange and not a lindex…That was a two day exercise in making my hair even more gray than it already is.

      Thank you for being there for me. You sparked me to rethink about where the problem was.

      Jodi

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

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,295
Replies
34,439
Topic Tags
287
Empty Topic Tags
10