Thread: getting number for Month

  1. #1
    Registered User
    Join Date
    Nov 2002

    getting number for Month

    Hi all,

    would like to ask if there are any function which convert month name to number(e.g. JUL ----> 07) ? or do i have to wrtie the function my self?

    second question, if i have to write that myself, does c# have functon like Select CASE in VB?

    thanks in advance

  2. #2
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    between photons and phonons
    I dont know of any function that will do it for you but writing it yourself isnt that hard.

    public string convertToNumbers(string month) {
    		case "JUL":
    			return "07";
    		case "AUG":
    			return "08";
    			return "00";
    I guess that is what you mean by a Select CASE in VB ( since I dont know any VB ).

  3. #3
    Registered User
    Join Date
    Aug 2004
    Im not sure how you are selecting your dates, but if your using a calander control you could pass the selected date to this

    string s = System.DateTime.Parse(System.DateTime.Now.ToString()).Month.ToString();
    instead of using System.DateTime.Now.ToString() you could just use the selected datetime from your calander control. i believe this should work.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help getting program print out the digit in words
    By cosmiccomputing in forum C Programming
    Replies: 26
    Last Post: 04-24-2008, 08:28 AM
  2. Need help with this compiler error
    By Evangeline in forum C Programming
    Replies: 7
    Last Post: 04-05-2008, 09:27 AM
  3. Prime number program problem
    By Guti14 in forum C Programming
    Replies: 11
    Last Post: 08-06-2004, 04:25 AM
  4. parsing a number
    By juancardenas in forum C Programming
    Replies: 1
    Last Post: 02-19-2003, 12:10 PM
  5. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 04:00 PM