g | x | w | all
Bytes Lang Time Link
087C gcc250819T154111ZToby Spe
113Java 8160623T070655ZKevin Cr
093Tcl180406T225259Zsergiol
061JavaScript ES6180411T001706Zl4m2
052J types/datetime240612T000710Zsouth
231TypeScript's type system240611T231912Znoodle p
023Uiua240611T163518Znoodle p
040Zsh + BSD/MacOS date240611T111722Zroblogic
061R240610T153740ZGlory2Uk
075Perl 5 p200226T205018ZXcali
064x8616 machine code230621T160936Z640KB
107Go230621T140513Zbigyihsu
013Japt P201102T124605ZShaggy
072Python230620T190440ZThe Empt
032Thunno 2230617T133911ZThe Thon
047Microsoft Excel VBA170813T193507ZTaylor R
115Python220206T173818ZOliver
056Factor220206T103136Zchunes
085Scala220206T094728Zcubic le
331Headascii220206T074527Zthejonym
078JavaScript Node.js210707T121229Zmekb
082Lua 5.3210707T005259ZdevRiche
037Vyxal o210706T204210Zemanresu
085Haskell201104T175444Zlynn
051Groovy201103T083918ZM. Justi
042Pyth201103T033316ZScott
040PowerShell160622T200435ZAdmBorkB
104C gcc180823T053843Zceilingc
065R180719T192116ZJayCe
155C tcc180720T144638Zfoemre
045Pyth180408T000953Zericesch
146PHP180409T185905ZFrancisc
078Base R180409T181641ZKamRa
065Caché ObjectScript180409T172245Zhomersim
029MediaWiki Template with ParserFunctions180408T040408Ztsh
055PHP180408T030808ZTitus
075Python180408T020012ZFRex
059K4180407T193534Zmkst
075C# 75 Bytes180406T192830ZRomen
103dc180406T171358Zbrhfl
085SmileBASIC180406T172709Z12Me21
142Java160916T122841ZShaun Wi
112R160623T144024Za soft p
096TSQL160805T133600Zdatagod
052Ruby 46 + 6 for rdate =160804T164412ZJordan
148Batch160622T230129ZNeil
149Swift 2.2160624T164554ZJAL
057Microsoft SQL Server160623T091356ZN.Y
078PHP160623T160855ZMarco
070Python 3160622T203051Zjqkul
078Factor160623T200507Zcat
034Japt160622T205016Znicael
066JavaScript ES6160622T202010ZDowngoat
112C160623T022848ZMarco
013MATL160622T204955ZSuever
087C#160623T142614Zraznagul
035jq160623T130540Zmanatwor
nanJava 7160623T103642Zcliffroo
039Pyth160623T091953ZLeaky Nu
070Retina160623T071741ZMartin E
049Oracle SQL160623T070644ZGiacomo
053Julia160622T233634ZAlex A.
070J160622T201954Zmiles
028Bash160622T205229ZMarco
018Bash + coreutils160622T211445ZDigital
079JavaScript160622T201121Znicael
04105AB1E160622T200901ZEmigna
042MATLAB / Octave160622T204404ZSuever
046CJam160622T200626ZNinjaBea
100Kotlin160622T202328ZRames
083Python160622T202129Zatlasolo

C (gcc), 87 bytes

#include<time.h>
f(char*s){struct tm t;strptime(s,"%Y%m",&t);strftime(s,6,"%^b%y",&t);}

This overwrites the input string in-place (fortunately, output is shorter than input). It uses GNU extension %^b to produce uppercase output.

Demo

This converts and prints each command-line argument. There's no checking of argument format or even length.

#include <stdio.h>
int main(int argc, char**argv)
{
    while (*++argv) {
        f(*argv);
        puts(*argv);
    }
}

Try it online!

Java 8, 154 113 bytes

import java.text.*;s->new SimpleDateFormat("MMMyy").format(new SimpleDateFormat("yyyyMM").parse(s)).toUpperCase()

Explanation:

Try it online.

import java.text.*;                 // Required import for SimpleDateFormat
s->                                 // Method with String as both parameter and return-type
  new SimpleDateFormat("MMMyy")     //  Create a formatter with format "MMMyy"
   .format(                         //  Format the following:
     new SimpleDateFormat("yyyyMM") //   Create another formatter with format "yyyyMM"
     .parse(s))                     //   Parse the input with this format
  .toUpperCase()                    //  Convert everything to Uppercase and return

Tcl, 93 bytes

proc C d {scan $d %2d%2d%2d d y m
format [string tou [clock f [clock sc $m/1] -f %b]]%02d $y}

Try it online!


# [Tcl], 96 bytes
proc C d {scan $d %2d%2d%2d d y m
format %s%02d [string tou [clock f [clock sc $m/1] -f %b]] $y}

Try it online!


# [Tcl], 98 bytes
proc C d {scan $d %2d%2d%2d d y m
format %s%02d [string tou [clock f [clock sc $m/1/0] -f %b]] $y}

Try it online!


# [Tcl], 115 bytes
proc C d {scan $d %2d%2d%2d d y m
format %s%02d [lindex {. JAN FEV MAR APR MAY JUN JUL AUG SEP OCT NOV DEC} $m] $y}

Try it online!

# [Tcl], 144 bytes
proc C d {scan $d %2d%2d%2d d y m
format %s%02d [string map {10 OCT 11 NOV 12 DEC 1 JAN 2 FEV 3 MAR 4 APR 5 MAY 6 JUN 7 JUL 8 AUG 9 SEP} $m] $y}

Try it online!

JavaScript ES6, 61 bytes

@Downgoat seems not there so I repost to optimize

a=>(new Date(0,a%100-1)+0).slice(4,7).toUpperCase()+a[2]+a[3]

Try it online!

J types/datetime, 52 bytes

2 3&{,~'MMM'toupper@fmtDate 1800 todayno@,1,~4".@}.]

A solution using one of J's libraries.

2 3&{,~'MMM'toupper@fmtDate 1800 todayno@,1,~4".@}.]
                                                   ]   NB. Input as string
                                             4   }.    NB. Drop 4 chars
                                              ".@      NB. Then eval as int
                                          1,~          NB. Append 1
                            1800         ,             NB. Prepend 1800
                                 todayno@              NB. Create date int
       'MMM'        fmtDate                            NB. Format the month as Jan,Feb,...
            toupper@                                   NB. Then uppercase it
2 3&{                                                  NB. Index the 3rd/4th char
     ,~                                                NB. Append it 

Attempt This Online!

TypeScript's type system, 231 bytes

type F<S>=S extends`${any}${any}${infer A}${infer B}${infer C}${infer D}`?`${[0,"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"][(C extends"0"?D:`${C}${D}`)extends`${infer N extends number}`?N:0]}${A}${B}`:S

Try it at the TS Playground

This should be 172 bytes:

type F<S>=S extends`${any}${any}${infer A}${infer B}${infer R extends number}`?`${[0,"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"][R]}${A}${B}`:S

but annoyingly TS doesn't let numeric types start with a 0 because that could be confused with legacy JavaScript octal literals, so this version just bugs out and we spend 59 bytes getting around that.

Uiua, 54 23 bytes

⊂⊡:⌵≡◇↙3Months-1⋕⊃↘↙⟜↘2

Try it online

TIL Uiua has a Months constant, thanks chunes

Zsh + BSD/MacOS date, 40 bytes

<<<${(U)$(date -jf %Y%m 20${1:2} +%b%y)}

It works for BSD date.
GNU date (as used by TIO) does not support j or f options.

I will think about making a GNU version. A relevant quote from the GNU manual:

Our units of temporal measurement, from seconds on up to months, are so complicated, asymmetrical and disjunctive so as to make coherent mental reckoning in time all but impossible. Indeed, had some tyrannical god contrived to enslave our minds to time, to make it all but impossible for us to escape subjection to sodden routines and unpleasant surprises, he could hardly have done better than handing down our present system. It is like a set of trapezoidal building blocks, with no vertical or horizontal surfaces, like a language in which the simplest thought demands ornate constructions, useless particles and lengthy circumlocutions. Unlike the more successful patterns of language and science, which enable us to face experience boldly or at least level-headedly, our system of temporal calculation silently and persistently encourages our terror of time.
… It is as though architects had to measure length in feet, width in meters and height in ells; as though basic instruction manuals demanded a knowledge of five different languages. It is no wonder then that we often look into our own immediate past or future, last Tuesday or a week from Sunday, with feelings of helpless confusion. (Robert Grudin, Time and the Art of Living.)

R, 61 bytes

toupper(format(as.Date(paste0(scan(,""),1),"%Y%m%d"),"%b%y"))

Try it online!

R, 62 bytes

(a former version featuring an addition of 10^7 to the date)

Despite that this question has already 3 answers in R, mine is slightly golfier than the shortest one and it's the only one which does not rely on the predefined month.abb vector.

To play fair, I have put my code onto TIO, which also meant I could not use the new shortcut function definition (=\(...))

If I understand correctly, apparently, there is a bug in the string parser and therefore the as.Date cannot read directly a string in "%Y%m" format.

My shortest solution (and this is code golf) was simply to paste a day number "1" at the end of the YYYYMM date, parse and output the desired format in uppercase letters.

Perl 5 -p, 75 bytes

$_=(1,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC)[/..$/g].substr$`,2,2

Try it online!

x86-16 machine code, 64 bytes

00000000: fcad ad50 ad2d 3030 86e0 d50a be19 0103  ...P.-00........
00000010: f003 f003 f02e a52e a458 abc3 4a41 4e46  .........X..JANF
00000020: 4542 4d41 5241 5052 4d41 594a 554e 4a55  EBMARAPRMAYJUNJU
00000030: 4c41 5547 5345 504f 4354 4e4f 5644 4543  LAUGSEPOCTNOVDEC

Callable function, input at DS:SI, output buffer at ES:DI.

Listing:

FC          CLD                         ; string direction forward 
AD          LODSW                       ; skip first two chars 
AD          LODSW                       ; load YY string 
50          PUSH AX                     ; save YY string 
AD          LODSW                       ; load month string 
2D 3030     SUB  AX, '00'               ; ASCII convert month 
86 E0       XCHG AH, AL                 ; endian convert 
D5 0A       AAD                         ; word convert to index (1-12) 
BE 0116     MOV  SI, OFFSET MTBL[-3]    ; month table (1-indexed) 
03 F0       ADD  SI, AX                 ; add month offset * 3 chars 
03 F0       ADD  SI, AX 
03 F0       ADD  SI, AX
2E A5   CS: MOVSW                       ; copy first two bytes of month
2E A4   CS: MOVSB                       ; copy third byte of month to output
58          POP  AX                     ; restore YY string 
AB          STOSW                       ; write YY to output 
C3          RET 
        MTBL: 
4A 41 4E    DB  'JAN' 
46 45 42    DB  'FEB' 
4D 41 52    DB  'MAR' 
41 50 52    DB  'APR' 
4D 41 59    DB  'MAY' 
4A 55 4E    DB  'JUN' 
4A 55 4C    DB  'JUL' 
41 55 47    DB  'AUG' 
53 45 50    DB  'SEP' 
4F 43 54    DB  'OCT'
4E 4F 56    DB  'NOV' 
44 45 43    DB  'DEC' 

Sample runs:

enter image description here

Go, 107 bytes

import(."time";."strings")
func f(s string)string{t,_:=Parse("200601",s)
return ToUpper(t.Format("Jan06"))}

Attempt This Online!

I wish Go's time formatting strings allowed all caps months like JAN06; that would save 22 bytes.

Japt -P, 14 13 bytes

ÐUò4)Åu ¸o¤Åë

Try it

ÐUò4)Åu ¸o¤Åë     :Implicit input of string U          > "201604"
Ð                 :Create Date object from
 Uò4              :  Partitions of U of length 4       > ["2016","04"]
    )             :End Date
     Å            :To date string                      > "Fri Apr 01 2016"
      u           :Uppercase                           > "FRI APR 01 2016"
        ¸         :Split on spaces                     > ["FRI","APR","01","2016"]
         o        :Modify the last element
          ¤       :  Slice off the first 2 characters  > ["FRI","APR","01","16"]
           Å      :Slice off the first element         > ["APR","01","16"]]
            ë     :Get every second element            > ["APR","16"]
                  :Implicitly join and output          > "APR16"

Python, 72 Bytes

lambda x:'JFMAMJJASONDAEAPAUUUECOENBRRYNLGPTVC'[int(x[4:])-1::12]+x[2:4]

Try it online!

Uses a stepping approach.

Thunno 2, 32 bytes

²ẸN“¤ɼḋġŀ§P¡^Ȥḥ)ñt:²æṆµṖƒr“R³İs+

Attempt This Online!

Explanation

²ẸN“...“R³İs+    # Implicit input        ->  "123405"
²                # Split into pairs      ->  ["12","34","05"]
 Ẹ               # Dump onto stack       ->  "12", "34", "05"
  N              # Cast to integer       ->  "12", "34", 5
   “...“         # Compressed string     ->  "12", "34", 5, "janfeb...novdec"
        R        # Uppercase it          ->  "12", "34", 5, "JANFEB...NOVDEC"
         ³       # Split into threes     ->  "12", "34", 5, ["JAN",...,"DEC"]
          İ      # One-based indexing    ->  "12", "34", "MAY"
           s+    # Swap and concatenate  ->  "12", "MAY34"
                 # Implicit output       ->  "MAY34"

Microsoft Excel VBA, 47 Bytes

Anonymous VBE immediate window function that takes input from range [A1] and outputs to the VBE immediate window

?UCase(MonthName([Right(A1,2)],1))[Mid(A1,3,2)]

Current version thanks to @Engineer Toast, for pointing out the abbreviate option of the MonthName function.

Previous Version

?UCase(Format(DateSerial([Left(A1,4)],[Right(A1,2)],1),"MMMYY"))

Python, 115 bytes

m='JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC'.split();d=input();print("%s%s"%(m[int(d[4]+d[5])-1],d[2]+d[3]))

Try it online

Factor, 56 bytes

[ 2 tail 2 cut dec> months "%b"strftime >upper prepend ]

Try it online!

Explanation

          ! "201604"
2         ! "201604" 2
tail      ! "1604"
2         ! "1604" 2
cut       ! "16" "04"
dec>      ! "16" 4
months    ! "16" T{ duration f 0 4 0 0 0 0 }
"%b"      ! "16" T{ duration f 0 4 0 0 0 0 } "%b"
strftime  ! "16" "Apr"
>upper    ! "16" "APR"
prepend   ! "APR16"

Scala, 85 bytes

s=>"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC".drop(30*s(4)+3*s(5)-1587).take(3)+s(2)+s(3)

The index lookup 30*s(4)+3*s(5)-1587 is a golfed version (via ASCII arithmetics) of the more readable s.slice(4,6).toInt*3-3.

Try it online!

I also tried the nice trick by @cliffroot to represent the names of the months via Chinese characters. This gives the following variant that is 23 characters shorter (62 instead of 85), but at the end 1 byte longer (86 instead of 85):

s=>""+BigInt(""+"憯䷳烣㘿烪摿摽㛨近筍矯䏔"(10*s(4)+s(5)-528),36)+s(2)+s(3)

Headascii, 331 bytes

UUU^U[UOUODOD]ONE.++++[]]]][]]]]+O[---[]]]][]]]][U]^U]OUOUOD++E.+++^^^U[U-()D]^P(]PD++++P:-()+++++]P-P---P:-()D+++]^P(]PD+++++P:-()]PD++++++]P++P:-()D^^^+++]P(]PD---]P:-()D^^]PD^++]PD-----]P:-()D^^]PD++]P(++^^^^^D+]P:-()]PD^^D++]P(++++++]P:D^^D^]P(++++]PD---]P;UPUP!.++^^^^^U[U)D^^++++]P(++]PD-]P:R-)D^^+++]P+PD+]P:+++]P+P--P;UPUP!

Try it here! Code will need to be pasted in and executed like this:

erun("UUU^U[UOUODOD]ONE.++++[]]]][]]]]+O[---[]]]][]]]][U]^U]OUOUOD++E.+++^^^U[U-()D]^P(]PD++++P:-()+++++]P-P---P:-()D+++]^P(]PD+++++P:-()]PD++++++]P++P:-()D^^^+++]P(]PD---]P:-()D^^]PD^++]PD-----]P:-()D^^]PD++]P(++^^^^^D+]P:-()]PD^^D++]P(++++++]P:D^^D^]P(++++]PD---]P;UPUP!.++^^^^^U[U)D^^++++]P(++]PD-]P:R-)D^^+++]P+PD+]P:+++]P+P--P;UPUP!","your input here")

Headass/ascii is not particularly good at strings.

UUU^U[UOUODOD]ONE. Block 0

UU                 Discard the first two chars of input lol
  U^U[             Hold onto the last two digits of the year
      UOUODOD]O    ready MMYY for the next code block
               NE  Go to block 1
                 . Block separator


++++[]]]][]]]]+O[---[]]]][]]]][U]^U]OUOUOD++E. Block 1

++++[]]]][]]]]+O                               Save 65 for later ease of access
                [---[]]]][]]]][                -48
                               U]^             Add to first month digit and hold
                                  U]O          Add to second month digit and save
                                     UOUO      Save year digits
                                         D++E  Go to either block 1 or block 2,
                                                depending on whether the first
                                                digit of the month was 0 or 1
                                             . Block separator


+++^^^U[U-()...;UPUP!.      Block 2 (JAN-SEP)

+++^^^                      Store 9 on the accumulator
      U[                    Restore 65 from earlier
        U-()                If the second digit of the month is 1,
D]^P(]PD++++P                 Concatenate "JAN" to the string register
             :-()           Else if it's 2
+++++]P-P---P                 Concatenate "FEB" to the string register
             :-()           Else if it's 3
D+++]^P(]PD+++++P             Concatenate "MAR" to the string register
                 :-()       Else if it's 4
]PD++++++]P++P                Concatenate "APR" to the string register
              :-()          Else if it's 5
D^^^+++]P(]PD---]P            Concatenate "MAY" to the string register
                  :-()      Else if it's 6
D^^]PD^++]PD-----]P           Concatenate "JUN" to the string register
                   :-()     Else if it's 7
D^^]PD++]P(++^^^^^D+]P        Concatenate "JUL" to the string register
                      :-()  Else if it's 8
]PD^^D++]P(++++++]P           Concatenate "AUG" to the string register
                   :        Else
D^^D^]P(++++]PD---]P          Concatenate "SEP" to the string register
               ;UPUP!       Then concatenate the year digits from earlier and print!
                     .      Block separator, end of execution


++^^^^^U[U)D^...;UPUP!  Block 3 (OCT-DEC)

++^^^^^                 Store 10 on the accumulator 
       U[               Restore 65 from earlier
         U)             If the second digit of the month is 0,
D^^++++]P(++]PD-]P        Concatenate "OCT" to the string register
                  :R-)  Else if it's 1
D^^+++]P+PD+]P            Concatenate "NOV" to the string register
              :         Else
+++]P+P--P                Concatenate "DEC" to the string register
          ;UPUP!        Then concatenate the year digits from earlier and print!

JavaScript (Node.js), 78 bytes

i=>'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'.match(/.../g)[i[4]+i[5]-1]+i[2]+i[3]

Try it online!

Lua 5.3, 82 bytes

i=io.read()print(os.date("%b%y",os.time({year=i//100,month=i%100,day=1})):upper())

Needs to be run on an english machine, as the month name is language specific.

Version that works in any locale 91 bytes

i=io.read()j=i%100*3 print(("JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"):sub(j-2,j)..i:sub(3,4))

Vyxal o, 37 bytes

4ȯI«×g~Þ¯p-Ḃ:u‹Ẇ¹²Ṗ¨€r;↓§%«3ẇ$‹i⇧₴4Ẏ∷

Try it Online!

4ȯI                # Month as int
   «...«3ẇ         # Compressed string of month names
          $‹i      # Get the correct month
             ⇧₴    # Uppercase and print
               4Ẏ∷ # Get the last two digits of year

Haskell, 85 bytes

f s=3`take`drop(read(drop 4s)*3-3)"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"++[s!!2,s!!3]

Try it online!

Groovy, 69 55 51 bytes

f={sprintf('%Tb',(it[4..5]as int)*22**7L)+it[2..3]}

Try it online!

This formats a millisecond value as an uppercase month name: sprintf('%Tb',value). The magic value of 22^7 is a value such that n * 22^7 milliseconds after epoch is in the nth month of the year of 1970. This value was derived by testing all possible 1 to 2 digit values. Therefore month * 22^7 will yield a value within that month.

  1. 1970-01-29
  2. 1970-02-27
  3. 1970-03-28
  4. 1970-04-26
  5. 1970-05-25
  6. 1970-06-23
  7. 1970-07-22
  8. 1970-08-19
  9. 1970-09-17
  10. 1970-10-16
  11. 1970-11-14
  12. 1970-12-13

Pyth, 42 bytes

Ac2>Q2+@c12."AY4H~0ë™~³!ò²×Œ¶7Ö"tiHTG

Try it online!

Ac2>Q2+@c12."AY4H~0ë™~³!ò²×Œ¶7Ö"tiHTG   // With Input '123405'

   >Q2                                       // Get input from index 2 (3405)
Ac2 ^                                        // Split it in two and assign to G and H (G='34', H='05'])
           ."AY4H~0ë™~³!ò²×Œ¶7Ö"             // Packed string representing: "JANFEBMAR..."
        c12."    JANFEBMAR...     "        // Chop it into 12 pieces (["JAN", "FEB", "MAR"...])
                                     tiHT    // Convert "05" to 5, subtract 1.
       @  ["JAN", "FEB", "MAR"...]   tiHT    // Get element at that index (MAY)
      +           "MAY"                  G   // "MAY" + 34

PowerShell, 49 46 40 bytes

date "$args".insert(4,'-')-U %b%y|% *per

Try it online!

Thanks to @Joey for saving 3 bytes!

Takes input $args as an explicit string (e.g., '201604') via command-line input. Uses the string.Insert() function to put a - in the appropriate space, and that resultant string forms input to the Get-Date cmdlet with the -Uformat parameter specifying the three-month shorthand plus two-digit year. We then tack on a .ToUpper() to make the output string capitalized. That string is left on the pipeline and printing is implicit.

Also, as pointed out, this is locale-sensitive. Here's the locale information that I'm using where this works correctly.

PS C:\Tools\Scripts\golfing> get-culture

LCID             Name             DisplayName
----             ----             -----------
1033             en-US            English (United States)

C (gcc), 107 104 bytes

main(){char s[7];gets(s+1);write(1,memcpy(s,"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"+~-atoi(s+5)*3,3),5);}

Try it online!

R, 65 bytes

function(A)paste0(toupper(month.abb[el(A:1)%%100]),substr(A,3,4))

Try it online!

Takes input as a string, leverages the constant month.abb. Uses modulus and substr to extract relevant values.

C (tcc), 155 bytes

Longest answer here.

main(i){char*k,s[6],*a="JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";gets(s);strcpy(k,s+2);memset(k+2,0,2);i=atoi(s+4)*3;memset(a+i,0,i);strcat(k,a+i-3);puts(k);}

Try it online!

Pyth, 45 bytes

+:."AYw2ûDÈëKH§È¼DYÉx\E±oË"J*3sgz5+3J:z2 4

Try it online!

Explanation:

+:."AYw2ûDÈëKH§È¼DYÉx\E±oË"J*3sgz5+3J:z2 4
                                z           Take the input
                               g 5          Slice inclusively from index 5 to the end
                              s             Parse as an int
                            *3              Multiply by 3
                           J                Store in variable J, this also returns J
 :                                          Take a slice
  ."AYw2ûDÈëKH§È¼DYÉx\E±oË"                 Of this packed string
                           J*3sgz5          From the J we defined before
                                  +3J       To J+3
+                                           To this string, append
                                     :z     A slice of the index
                                       2 4  From [2,4).

The packed string contains "JANJANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC". The two JANs are so that I can index it pseudo-one-indexed.

EDIT: Fixed bug that was messing with TIO

PHP, 146 Bytes.

Manipulating string

Code Try it online

function f($d){echo strtr(ltrim(substr($d,-2),'0'),array_combine(range(1,12),
str_split(JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC,3))).substr($d,2,-2);}

Explanation

function f($d){
                                #strtr allows u to set an array to replace the ocurrences
echo strtr(ltrim(substr($d,-2),'0'),        #Substring of the last two numbers of the input, 
                                           #removing leading zero
    array_combine(range(1,12),      
    str_split(JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC,3)))
                                           #create an array of ["1"=>JAN, "2"=>FEB...12=>DEC], 
                                           #split the string by 3 characters
    .substr($d,2,-2);
                                           #Concatenate the 2 middle characters
}

Base R, 78 bytes

paste(casefold(month.abb,upper=T)[strtoi(substr(A,5,6))],substr(A,3,4),sep="")

Not sure if this is required to be formatted as a standalone function, but if so, it is 91 bytes:

function(A){paste(casefold(month.abb,upper=T)[strtoi(substr(A,5,6))],substr(A,3,4),sep="")}

Caché ObjectScript - 65 bytes

Golfed

r i s d=$zcvt($zd($zdth(i_"01",8),6),"u") w $e(d,1,3)_$e(d,*-1,*)

Ungolfed

r i                            ; Read stdin and store into 'i'                      [200203]
   s d=                        ; Set the variable 'd' to the following...
       $zcvt(                  ; Convert the string
             $zd(              ; Parse the string as a caché date
                 $zdth(        ; Convert the date to horolog format (# days from 12/31/1840)
                       i_"01", ; Append the string "01" to variable 'i'             [20020301]
                       8       ; Use format #8 - "YYYYMMDD" (e.g. 20020301)
                      ),                                                            [58864,0]
                 6             ; Use format #6 - "Mmm [D]D YYYY" (e.g. Mar 1 2002)
                ),                                                                  [Mar 1 2002]
             "u"               ; Convert the string to uppercase
            )                                                                       [MAR 1 2002]
   w                           ; Write out the following...
     $e(d,1,3)                 ; Extract the substring from position 1 to 3 (inclusive) [MAR]
     _                         ; Concatenate
     $e(d,                     ; Extract the substring...
        *-1,                   ; ...from 1 character from the end of the string     [0]
        *                      ; ...to the last character                           [2]
       )                                                                            [02]
                                                                                    [MAR02]

Commentary

I don't think I've ever seen another Caché answer on this site. I'm only forced to know the language because of work (legacy code), but language itself is very powerful.

Some notes about the language:

Unfortunately, there is no online interpreter for Caché. Probably either because it's too obscure or maybe a licensing thing.

If you're interested in the language, you can check out their docs on their very 90's looking website :)

MediaWiki Template (with ParserFunctions), 29 bytes

{{uc:{{#time:My|{{{1}}}01}}}}

Only works if English locale is chosen.

Try Sandbox

PHP, 55 bytes

<?=date(My,strtotime(wordwrap($argn,4,"-",1)))&"___??";

Run as pipe with -n or try it online. Requires PHP 5 or later.

Python, 75 bytes

Here is my obvious Python lambda, takes and returns a string, hope I didn't miss some obvious hole:

lambda x:"JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"[3*int(x[4:])-3:][:3]+x[2:4]

K4, 65 59 bytes

Solution:

@[13 3#"DECJANFEBMARAPRMAYJUNJULAUGSEPOCTNOV";.*|x],*x:2 4_

Examples:

q)k)@[13 3#"DECJANFEBMARAPRMAYJUNJULAUGSEPOCTNOV";.*|x],*x:2 4_"201604"
"APR16"
q)k)@[13 3#"DECJANFEBMARAPRMAYJUNJULAUGSEPOCTNOV";.*|x],*x:2 4_"200001"
"JAN00"
q)k)@[13 3#"DECJANFEBMARAPRMAYJUNJULAUGSEPOCTNOV";.*|x],*x:2 4_"000112"
"DEC01"
q)k)@[13 3#"DECJANFEBMARAPRMAYJUNJULAUGSEPOCTNOV";.*|x],*x:2 4_"123405"
"MAY34"

Explanation:

Reshape the months of the year so that 0 => DEC and 1 => JAN ... 12 => DEC.

@[13 3#"DECJANFEBMARAPRMAYJUNJULAUGSEPOCTNOV";.*|x],*x:2 4_ / the solution
                                                       2 4_ / cut input at indices 2 & 4, "201604" => ["16", "04"]
                                                     x:     / save as x
                                                    *       / take first
                                                   ,        / join with
@[                                           ;    ]         / apply @[list;index]
                                               *|x          / reverse (|), first (*) aka 'last'
                                              .             / value ("05" => 5)
       "DECJANFEBMARAPRMAYJUNJULAUGSEPOCTNOV"               / offset months of the year
  13 3#                                                     / reshape

Bonus:

60 byte version in K (oK):

((13 3#"DECJANFEBMARAPRMAYJUNJULAUGSEPOCTNOV")@.*|x),*x:2 4_

Try it online!

C# - 75 Bytes

s=>{return new System.DateTime(s/100,s%100,1).ToString("MMMyy").ToUpper();}

dc, 103 bytes

[0n]sP[JAN][FEB][MAR][APR][MAY][JUN][JUL][AUG][SEP][OCT][NOV][DEC]Csi[lid1-si:mz1<M]dsMxA0~;mPA0~dZ2>Pp

Try it online!

[0n]sP is a macro that just prints a 0 w/o a newline for the sake of padding 1-9.

[JAN]...[DEC] places the strings on the stack. Csi[lid1-si:mz1<M]dsMx is a macro that decrements i from 12, popping the strings off of the stack and placing them at index i in the array m. Stops when one item (input) is left on the stack.

100~;mP does quotient/remainder division by 100, and prints the value from m indexed by the remainder. The quotient is left on the stack. 100~dZ2>Pp again gets the remainder after dividing by 100, runs the padding macro P this is one digit long, and then prints.

Without any way of manipulating strings, I don't think that part is golfable. Doing any sort of wizardry with JAN/JUN/JUL would likely take far more bytes than the strings themselves.

SmileBASIC, 85 bytes

DEF C D?MID$(@__JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC,VAL(D[4]+D[4])*3,3);D[2];D[3]END

@__JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC is equivalent to the string literal "@__JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC". JAN starts at index 3, so the program can calculate the position as month*3 instead of (month-1)*3 or month*3-3.

Java, 142 bytes

s->(new String[]{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"})[Integer.decode(s.substring(4))-1]+s.substring(2,4);

R, 154 150 114 112 bytes

Takes six digit input into "b", separates the first four digits from the last two digits, abbreviates the 2-digit month and makes it uppercase, and concatenates it with the 3rd and 4th digit.

Golfed:

function(b){h=substr;i=sprintf;o="%06d";cat(toupper(month.abb[as.numeric(h(i(o,b),5,6))]),h(i(o,b),3,4),sep="")}

Ungolfed:

function(b){
   h=substr;i=sprintf;o="%06d";

   cat(
      toupper(month.abb[as.numeric(h(i(o,b),5,6))]),
      h(i(o,b),3,4),
   sep="")
}

EDITS: replaced duplicitous names with variables; fixed me being stupid. -2 bytes by turning function anonymous (thanks, cat).

T-SQL, 96 bytes

declare @i varchar(8)
select  @i = '201604'
select upper(left(datename(month,@i+'01'),3)) + substring(@i,5,2)

Ruby 46 + 6 for -rdate = 52

For completeness, if nothing else.

->d{Date.strptime(d,'%Y%m').strftime('%^b%y')}

See the tests on repl.it: https://repl.it/Cj7z

Batch, 148 bytes

@set d=%1
@for %%m in (JAN.01 FEB.02 MAR.03 APR.04 MAY.05 JUN.06 JUL.07 AUG.08 SEP.09 OCT.10 NOV.11 DEC.12)do @if %%~xm==.%d:~4% echo %%~nm%d:~2,2%

No date libraries to speak of so manual parsing ftw. I don't know whether the rules of Code Golf allow creating 12 appropriately-named files in the current directory, resulting in something like this:

@set d=%1
@for %%m in (*.%d:~4%)do @echo %%~nm%d:~2,2%

Swift 2.2, 149 bytes

let f = NSDateFormatter(),g = NSDateFormatter();f.dateFormat = "yyyyMM";g.dateFormat = "MMMyy"
g.stringFromDate(f.dateFromString(i)!).uppercaseString

Trying to get this shorter than Kotlin... It's a shame NSDateFormatter doesn't have an initializer that sets its dateFormat. NSDateFormatter also does not have a default dateFormat value, causing additional losses.

Swift 3, 136 bytes

let f = DateFormatter(),g = DateFormatter();f.dateFormat = "yyyyMM";g.dateFormat = "MMMyy"
g.string(from: f.date(from: i)!).uppercased()

Thanks to the removal of the NS prefix on some classes, I was able to make the Swift 3 answer a little shorter. Still not shorter than Kotlin though...

Test function and cases:

import Foundation
import XCTest

func dateConverter(i: String) -> String? {
    let f = DateFormatter(),g = DateFormatter();f.dateFormat = "yyyyMM";g.dateFormat = "MMMyy"

    if let date = f.date(from: i) {
        return g.string(from: date).uppercased()
    }

    return nil
}

XCTAssert(dateConverter(i: "201604") == "APR16")
XCTAssert(dateConverter(i: "200001") == "JAN00")
XCTAssert(dateConverter(i: "000112") == "DEC01")
XCTAssert(dateConverter(i: "123405") == "MAY34")

Microsoft SQL Server, 57 Bytes

SELECT UPPER(FORMAT(CAST('201601'+'01' AS DATE),'MMMyy'))

The Upper function is required as format does not produce Upper case months as would be expected with the MMM format pattern.

Usage:

drop table t;
create table t (n VARCHAR(6));
insert into t values ('201604');
insert into t values ('200001');
insert into t values ('000112');
insert into t values ('123405');    

SELECT UPPER(FORMAT(CAST(n+'01' AS DATE),'MMMyy')) FROM t

PHP, 78 bytes

<?=fscanf(STDIN,"%4d%d",$y,$m)?strtoupper(date("My",mktime(0,0,0,$m,1,$y))):0;

The "year 2038 problem" may occur on some computers, as here. But not in others, as here.

Python 3, 70 bytes

from time import*
lambda s:strftime("%b%y",strptime(s,"%Y%m")).upper()

This uses the built-in strftime and strptime functions.

For 1 byte more, here's a version which parses the string manually:

lambda s:" JFMAMJJASONDAEAPAUUUECOENBRRYNLGPTVC"[int(s[4:])::12]+s[2:4]

This encodes the month names in an interesting way (thanks to Henry Gomersall for saving a byte).

Factor, 82 78 bytes

[ [ 2 tail* 10 base> month-abbreviation ] [ 4 head 2 tail ] bi append >upper ]

Eshplained:

[                    ! new anonymouse function block (quotation)
  [                  ! new quotation 
    2 tail*          ! "201604" -> "04"
    10 base>         ! "04"     -> 4
    month-abbreviation ! 4 -> "Apr"
  ]                  ! end quotation
  [                  ! new quotation
    4 head           ! "201604" -> "2016"
    2 tail           ! "2016"   -> "16" 
  ]                  ! end quotation
  bi                 ! bifurcate two quotations to TOS
  append             ! "Apr" "16" -> "Apr16"
  >upper             ! "Apr16"    -> "APR16"
]                    ! end quotation

Japt, 35 34 bytes

ÐUr$/..../$,"$&-")+P s4,7 u +Us2,4

Link.

Uses the same technique as my JavaScript answer.

JavaScript ES6, 77 66 bytes

Saved 11 bytes thanks to @Bálint!

a=>(new Date(0,a[4]+a[5]-1)+"").slice(4,7).toUpperCase()+a[2]+a[3]

Get's the date by extracting the string returned by the Date class. then capitalizes and adds the year.

ES5 version:

var a = prompt("Enter YYYYMM: ");
result = (new Date(0,a[4]+a[5]-1)+"").slice(4,7).toUpperCase()+a[2]+a[3]
alert(result);

C, 147 145 112 bytes

main(m){char a[99]="JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";scanf("%4s%d",a+50,&m);printf("%.3s%s",a+--m*3,a+52);}

Online demo

Thanks ugoren!

MATL, 18 14 13 bytes

4e!Z{Zc12XOXk

Input is provided as a string (enclosed in single quotes).

This version only runs in MATL on MATLAB since MATLAB is able to automatically parse datestr('2016 04').

Explanation

        % Implicitly grab input as a string
4e!     % Reshape input to be 2 x 4 (puts the year in row 1 and month in row 2)
Z{      % Place each row in a separate cell
Zc      % Join them together using a space to create 'yyyy mm' format
12      % Number literal, pre-defined datestring of 'mmmyy'
XO      % Convert from serial date number to string using this format
Xk      % Convert to uppercase
        % Implicitly display
    

Here is an 18 byte version which works on Octave (and therefore the online interpreter)

'yyyymm'2$YO12XOXk

Try it Online

Modified version for all test cases

Explanation

            % Implicitly grab input as a string
'yyyymm'    % Push the format string as a string literal
2$YO        % Convert to a serial date number
12          % Number literal, pre-defined datestring of 'mmmyy'
XO          % Convert from serial date number to string using this format
Xk          % Convert to uppercase
            % Implicitly display

C#, 94 87 bytes

string C(string s)=>System.DateTime.Parse(s.Insert(4,"-")).ToString("MMMyy").ToUpper();

Saved 7 bytes by using C#6 Syntax.

Try Online

jq, 35 characters

(34 characters code + 1 character command-line option.)

(Just tried whether the ^ trick used by Digital Trauma in his Bash answer works in jq too. Works. Now you know who inspired the most important character of this answer. (The alternative is to use the ascii_upcase function.))

strptime("%Y%m")|strftime("%^b%y")

Sample run (Option -R used only in this sample to pass all test cases.)

bash-4.3$ jq -Rr 'strptime("%Y%m")|strftime("%^b%y")' <<END
201604
200001
000112
123405
END
APR16
JAN00
DEC01
MAY34

On-line test: (Passing -R through URL is not supported – so input passed as JSON string literal. Passing -r through URL is not supported – check Raw Output yourself.)

Java 7, 137 characters (161 bytes)

String d(String i){return Integer.toString("憯䷳烣㘿烪摿摽㛨近筍矯䏔".charAt(Integer.parseInt(i.substring(4))-1),36).toUpperCase()+i.substring(2,4);}

Consider each month name (JAN, FEB etc...) is a number in base 36 and encode it into corresponding Unicode symbol. Then get corresponding symbol from the string encode it back again in base 36 and after that some plain string manipulations.

Slightly ungolfed:

String d(String input){
return 
  Integer.toString("憯䷳烣㘿烪摿摽㛨近筍矯䏔" // encoded month names
  .charAt(Integer.parseInt(input.substring(4))-1),36) // get a symbol from encoded names at position input[4:], decode it to base 36 value
  .toUpperCase()+input.substring(2,4); // get it to upper case and add year
}

You can see it running here: https://ideone.com/IKlnPY

Pyth, 39 bytes

Hexdump:

0000000: 2b 40 63 2e 22 41 59 12 56 0a 7c bd 93 e3 1c 07 +@c."AY.V.|.....
0000010: e3 d4 d9 ed 5b 49 02 cd b4 92 83 86 22 33 73 3e ....[I......"3s>
0000020: 32 7a 3a 7a 32 20 34                            2z:z2 4

Test suite.

Retina, 71 70 bytes

Thanks to Sp3000 for saving 1 byte.

Byte count assumes ISO 8859-1 encoding. The trailing linefeed is significant.

(..)(..)$
DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJANXXX$2$*¶$1
+`...¶

R-6`.

Try it online!

Explanation

Taking 201604 as an example:

(..)(..)$
DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJANXXX$2$*¶$1

This swaps the last two digits of the year with the month while also expanding the month in unary using linefeeds, and prepending the list of months in reverse so we'd get:

20DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJANXXX¶¶¶¶16

Where the represent linefeeds (0x0A).

+`...¶

Now we repeatedly remove three non-linefeed characters followed by a linefeed. That is we eat up the list of months from the end for each linefeed representing a month:

20DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJANXXX¶¶¶¶16
20DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJAN¶¶¶16
20DECNOVOCTSEPAUGJULJUNMAYAPRMARFEB¶¶16
20DECNOVOCTSEPAUGJULJUNMAYAPRMAR¶16
20DECNOVOCTSEPAUGJULJUNMAYAPR16

This is why we've inserted that XXX: since the months start counting from 1, we'll always remove at least three characters, even for January.

R-6`.

Finally, we remove everything up to the 6th character from the end. In other words we only keep the last five characters.

Oracle SQL, 49 Bytes

select to_char(to_date(n,'yyyymm'),'MONyy')from t

The data must be inserted in a table called T with a column N of type VARCHAR2(6), CHAR(6) or , only if all the years are > 1000, NUMBER

Usage:

drop table t;
create table t (n VARCHAR2(6));
insert into t values ('201604');
insert into t values ('200001');
insert into t values ('000112');
insert into t values ('123405');    

select to_char(to_date(n,'yyyymm'),'MONyy')from t;

Julia, 57 56 53 bytes

s->uppercase(Dates.format(DateTime(s,"yyyym"),"uyy"))

This is an anonymous function that accepts a string and returns a string. To call it, assign it to a variable.

First we construct a DateTime object using the type constructor and a format string. Note that the single m in the format string will get both one- and two-digit months, though the former case is irrelevant here. Since no days are specified, the first of the month is assumed.

We can then format the value as a string using the Dates.format function from the Base.Dates submodule. The string uyy gets the three-letter month name and two-digit year, but the result is in title case, e.g. Apr16 instead of the desired APR16, so we need to uppercase it.

Try it online! (includes all test cases)

J, 70 bytes

4(}.((,~(_3]\'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'){~1-~".)~2&}.){.)]

Usage

   f =: 4(}.((,~(_3]\'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'){~1-~".)~2&}.){.)]
   f '201604'
APR16
   f '200001'
JAN00
   f '000112'
DEC01
   f '123405'
MAY34

Explanation

4(}.((,~(_3]\'...'){~1-~".)~2&}.){.)] Input: s
                                    ] Identity function, gets the value s
4                                     The constant 4
                                 {.   Take the first 4 chars from s
                            2&}.      Drop the first 2 (Take the last 2) to get the year
  }.                                  Drop the first 4 chars from s to get the month
                        ".            Parse the month substring as a number
                     1-~              Subtract 1 from it
             '...'                    List of MMM month names
         _3]\                         Split the list into nonoverlapping sublists of size 3
      ,~                              Join the MMM month name with the year and return

Bash, 39 28 bytes

date -d$101 +%b%y|tr a-z A-Z

Thanks Digital Trauma!

Bash + coreutils, 18

Requires 64-bit version of date for the given testcases, which recognises dates earlier than 14th December 1901.

date -d$101 +%^b%y

JavaScript, 87 84 80 79 bytes

x=>(new Date(x.replace(/.{4}/,'$&-'))+'').slice(4,7).toUpperCase()+x.slice(2,4)

To get the month, gets the date (which is formed of "YYYYMM" converted to "YYYY-MM") and retrieves the characters 5 to 8, that are exactly the first three letters of the month. But it costs much to convert it to upper case.

Demo:

function s(x) {
  return (new Date(x.replace(/.{4}/, '$&-')) + '').slice(4,7)
         .toUpperCase() + x.slice(2, 4)
}

console.log(s('201604'));
console.log(s('200001'));
console.log(s('000112'));
console.log(s('123405'));

05AB1E, 51 42 41 bytes

2ô¦`ï<•r–ºþ¯Bê€õaPù£—^5AºüLwÇ–è•35B3ôsèsJ

Explanation

                                           # implicit input, 123405
2ô                                         # split input into pieces of 2, ['12','34','05']
  ¦`                                       # push last 2 elements to stack, '05', '34'
    ï<                                     # convert month to its int index, 4
      •r–ºþ¯Bê€õaPù£—^5AºüLwÇ–è•35B        # get compressed string containing 3-letter months, 
                                             JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC
                                   3ô      # split into pieces of 3
                                             ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC']
                                     sè    # get month at index retrieved earlier, MAY
                                       sJ  # join with 2-digit year and implicitly print, MAY34

Try it online

9 bytes saved thanks to string compression, courtesy of @Adnan

MATLAB / Octave, 42 bytes

@(x)upper(datestr(datenum(x,'yyyymm'),12))

Creates an anonymous function named ans that is called with a string representing the date: ans('201604').

Online Demo

This solution uses datenum to convert the input date to a serial date number, and then datestr with the predefined output spec of mmmyy (12) to yield the string representation in the required format. Finally, we use upper to change it to MMMYY since the uppercase month is not an output option.

CJam, 50 46 bytes

q2/1>~i("4H~0ë~³!ò²×¶7Ö"256b25b'Af+3/=\

Try it online. Thanks to Martin Ender for compressing the string to save a few bytes.

Explanation

q2/  e# Get input and divide it into groups of 2, like ["20" "16" "04"]
1>~  e# Discard the first item and dump the remaining array to the stack
i(   e# Convert the top value (month) to an integer and decrement it, because
     e# arrays are zero-indexed
"..."256b25b e# Convert this string from base-256 to base-25
'Af+ e# "Add" a capital A to each number to get the letters
3/   e# Divide into groups of 3 to make an array of month names
=\   e# Get the requested month and swap the elements to put the year on
     e# top, so it is printed last

Kotlin, 100 bytes

fun f(d:String)=SimpleDateFormat("MMMyy").format(SimpleDateFormat("yyyyMM").parse(d)).toUpperCase()

Pretty straight forward use of Java SimpleDateFormat

Python, 83 bytes

from datetime import*
lambda x:datetime.strptime(x,'%Y%m').strftime('%b%y').upper()