473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Month Name in c# (August)

Hello,

What I am trying to do is get the string(August) from:
hdnMonth.Value = DateTime.Now.Month.ToString();

Does c# have a function like the vb function "MonthName" ?
hdnMonth.Value = CType(MonthName(Month(Now())), String)

Thanks, sck10
Aug 11 '06 #1
4 19048
Hi,

sck10 wrote:
Hello,

What I am trying to do is get the string(August) from:
hdnMonth.Value = DateTime.Now.Month.ToString();

Does c# have a function like the vb function "MonthName" ?
hdnMonth.Value = CType(MonthName(Month(Now())), String)

Thanks, sck10
You don't say in which culture, so I am going to assume you want it in
the current culture:

string monthName
= CultureInfo.CurrentCulture.DateTimeFormat.GetMonth (
DateTime.Now.Month );

Note that with GetMonth, 1 returns January and not 0 like you would have
expected.

Note also that GetMonth can accept 1 to 13, with 13 returning an empty
string.

http://msdn.microsoft.com/library/de...hnametopic.asp

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 11 '06 #2
"sck10" <sc***@online.nospamwrote in message
news:ef**************@TK2MSFTNGP02.phx.gbl...

What I am trying to do is get the string(August) from:
hdnMonth.Value = DateTime.Now.Month.ToString();

Does c# have a function like the vb function "MonthName" ?
hdnMonth.Value = CType(MonthName(Month(Now())), String)
Easy as pie...

string strMonth = DateTime.Now.ToString("MMMM");
Aug 11 '06 #3
Thanks for Laurent and Mark's informative input.

Hi Steve,

As Mark has mentioned, as simple way to get the long month name of the date
is use the DateTime object ToString method and supply the "MMMM" format
string. Also, the below statement will only return the month name
associated with the current thread's CultureInfo

Response.Write("<br/>" + date.ToString("MMMM"));

if you want to return the culture-neutral (english) month name, you can
also supply the "InvariantCulture" formatter info.

Response.Write("<br/>" + date.ToString("MMMM",
CultureInfo.InvariantCulture));

Here are some useful info about common date/time formatting in .net
framework:

#Custom DateTime Format Strings
http://msdn.microsoft.com/library/en...omdatetimeform
atstrings.asp?frame=true

#Standard DateTime Format Strings
http://msdn.microsoft.com/library/en...darddatetimefo
rmatstrings.asp?frame=true

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 14 '06 #4
Hi Steven,

Thanks for the links. Appreciate it...
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:lV**************@TK2MSFTNGXA01.phx.gbl...
Thanks for Laurent and Mark's informative input.

Hi Steve,

As Mark has mentioned, as simple way to get the long month name of the
date
is use the DateTime object ToString method and supply the "MMMM" format
string. Also, the below statement will only return the month name
associated with the current thread's CultureInfo

Response.Write("<br/>" + date.ToString("MMMM"));

if you want to return the culture-neutral (english) month name, you can
also supply the "InvariantCulture" formatter info.

Response.Write("<br/>" + date.ToString("MMMM",
CultureInfo.InvariantCulture));

Here are some useful info about common date/time formatting in .net
framework:

#Custom DateTime Format Strings
http://msdn.microsoft.com/library/en...omdatetimeform
atstrings.asp?frame=true

#Standard DateTime Format Strings
http://msdn.microsoft.com/library/en...darddatetimefo
rmatstrings.asp?frame=true

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Aug 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: manning_news | last post by:
Using SQL 2000. I need to select rows based on a date range. Both the beginning date and ending date of the range will be entered in the mm/dd/yy format. There are 2 columns in the table called...
4
by: wolftor | last post by:
Month(date) shows the month number. Is there a way to get the month name ie. October? -- Regards, Peter
3
by: wolftor | last post by:
Month(date) shows the month number. Is there a way to get the month name ie. October? -- Regards, Peter
2
by: Guoqi Zheng | last post by:
I know now.dayofweek can return week name, but it is something like, monday, tuesday, I only need to return Mon to represent monday. And for month name, I only need to have jan, Feb, etc. short...
1
by: bbpitpit | last post by:
hi there, i'm new here, can i know how to display the month name from database's datetime? for example: in database the date column storing 12/03/2006 and I want to display only it's month name...
2
by: CindySue | last post by:
Hello--I've got a query that uses DatePart("m",) to select records for a particular month, and then a report based on that query. I'd like to be able to create a field in the report that says what...
2
by: sachin shah | last post by:
Hi all i want result as month name from my query i tried with the following query but it give result as month number like (8) select (month(getdate())) as expr i want result as month...
5
by: girl23 | last post by:
I am using a function prototype to convert month number to month name. basically you ask the compiler to enter int from 1 to 12 and then convert it. printMonth ( number ); is the prototype and...
12
by: Be Borth | last post by:
I saw previous solutions to convert a month number (1) to a month name (January). I have a database with 200+ dates. In a query, I use the "Part" function DatePart("m",), to extract the month...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.