FastPrepWrite a Numeric Date in Words
Problems/Write a Numeric Date in Words

Write a Numeric Date in Words

Capital One logoCapital One● EasyINTERNFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two Capital One reports from 2019 ask for a date written with digits to be turned into words with an ordinal day, such as 1st or 10th. One comes from an on-campus interview with two coding questions and wants an abbreviated month plus the year. The other, from an on-site interview day, wants the full month and no year.

This version takes a zero-padded month-day-year date and returns the full month name, the day with its suffix, a comma and the four-digit year. The date format and range are our choice.

Our version is about 85% the same as the reported questions.

date is a real calendar date written as "MM-DD-YYYY", with a two-digit month, a two-digit day and a four-digit year. Return it in words: the full English month name, a space, the day without leading zeros followed by its ordinal suffix, a comma, a space, and the year.

The suffix is st, nd or rd for days ending in 1, 2 or 3, and th otherwise. Days 11, 12 and 13 always take th.

Function

formatDate(date: String) → String

Examples

Example 1

date = "03-22-2024"return = "March 22nd, 2024"

Month 03 is March. Day 22 ends in 2, so it takes nd. The year stays as written.

Example 2

date = "11-13-1999"return = "November 13th, 1999"

Day 13 ends in 3, but 11, 12 and 13 are exceptions that always take th, so it is 13th, not 13rd.

Example 3

date = "07-01-2031"return = "July 1st, 2031"

The leading zero of the day is dropped: 01 becomes 1st.

Example 4

date = "10-03-2012"return = "October 3rd, 2012"

Day 03 ends in 3 and is not a teen, so it takes rd: 3rd.

Example 5

date = "12-11-1990"return = "December 11th, 1990"

Day 11 ends in 1, but like 12 and 13 it takes th, so it is 11th, not 11st.

Constraints

  • date has the form "MM-DD-YYYY" and names a real date.
  • The year is between 1900 and 2100.

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Christmas Tree with N TiersVerily · ONSITE INTERVIEW
  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
  • Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
  • Palindrome Check Ignoring SymbolsWalmart · ONSITE INTERVIEWWalmart interview questions
  • Reverse a String Keeping Dashes in PlaceNykaa · ONSITE INTERVIEWNykaa interview questions
  • Implement tail -nConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Valid ParenthesesEPAM · ONSITE INTERVIEWEPAM interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 Experiences
  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public String formatDate(String date) {
        // Write your code here.
    }
}
Checking account…