Convert "Jan" to "01"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nico3334
    New Member
    • Aug 2007
    • 28

    Convert "Jan" to "01"

    Hi,

    I am trying to convert a month data field column from "Jan" to "01". Or for february: "Feb" to "02". So the month displays in "mm" format.

    Can someone help me code this in VB?

    Thanks
  • YarrOfDoom
    Recognized Expert Top Contributor
    • Aug 2007
    • 1243

    #2
    This can easily be done with select case I think...
    Just get your value, set up the whole "select case"-thing and store the become value.
    eg:
    [code=vb]select case inputvariable
    case "Jan"
    inputvariable = "01"
    case "Feb"
    inputvariable = "02"
    ...
    case "Dec"
    inputvariable = "12"
    end select[/code]

    Yarr

    Comment

    • nico3334
      New Member
      • Aug 2007
      • 28

      #3
      Originally posted by yarrofdoom
      This can easily be done with select case I think...
      Just get your value, set up the whole "select case"-thing and store the become value.
      eg:
      [code=vb]select case inputvariable
      case "Jan"
      inputvariable = "01"
      case "Feb"
      inputvariable = "02"
      ...
      case "Dec"
      inputvariable = "12"
      end select[/code]

      Yarr
      Thank you for your help!

      Just to build on that question. Is there a way to display "01" from a field that displays a full date: 1/1/2007.

      For example, if the date displayed was 7/4/2007, I want to covert it to "07".

      Thanks!

      Comment

      • jaz215
        New Member
        • Nov 2007
        • 55

        #4
        if your getting it directly from the database what you can do is convert to a string then break down the date then just select case 1 = 01 then place in in the another string and display it..

        hope this helps :P

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Originally posted by nico3334
          Thank you for your help!

          Just to build on that question. Is there a way to display "01" from a field that displays a full date: 1/1/2007.

          For example, if the date displayed was 7/4/2007, I want to covert it to "07".

          Thanks!
          Hi,
          use "Format" Function.
          Check these:

          [code=vb]
          Text1.Text = Format("7/4/2007","dd-mm-yyyy")
          Text2.Text = Format("7/4/2007","dd-mmm-yyyy")
          Text3.Text = Format("7/4/2007","dd-mm-yyyy dddd")
          Text4.Text = Format("7/4/2007","dd-mm-yyyy ddd")
          [/code]

          Regards
          Veena

          Comment

          Working...