Hi i want to convert an integer value into datetime(mmm-yyyy) format can u help?
example: i have integer value :6 now i want to convert this 6 into Jun-2013 How can i convert.
example: i have integer value :6 now i want to convert this 6 into Jun-2013 How can i convert.

Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 15, 2013, 10:58 PM EDT
try like this
using System.Globalization;
string strMonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(8);
pass the number to get it as text.
if you want current year concat it with month.
like this
DateTime dt = new DateTime(2013, 6, DateTime.Now.Day);
string date = dt.ToString("MMM-yyyy");
Riyaz AkhtarRank #2,275 · 619 reputationPosted Jul 15, 2013, 10:58 PM EDT
Syed ShanuRank #87 · 23.7K reputationPosted Jul 16, 2013, 2:18 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 16, 2013, 7:02 PM EDT
hi,
if your are looking in c# than try
string dtName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(6) + " - " + DateTime.Now.Year.ToString();
or if you are looking in SQL
DECLARE @monthName INT =6
Select DateName(month ,DateAdd( month ,@monthName,0 )- 1) + ' - ' + CAST(YEAR(getdate()) AS VARCHAR)
hope this will help you.
Ifour Hiren61 reputationPosted Nov 3, 2016, 1:15 AM EDT
String.Format("{0:M MM MMM MMMM}", dt); // "3 03 Mar March" month
String.Format("{0:d dd ddd dddd}", dt); // "9 09 Sun Sunday" day
String.Format("{0:h hh H HH}", dt); // "4 04 16 16" hour 12/24
String.Format("{0:m mm}", dt); // "5 05" minute
String.Format("{0:s ss}", dt); // "7 07" second
String.Format("{0:f ff fff ffff}", dt); // "1 12 123 1230" sec.fraction
String.Format("{0:F FF FFF FFFF}", dt); // "1 12 123 123" without zeroes
String.Format("{0:t tt}", dt); // "P PM" A.M. or P.M.
String.Format("{0:z zz zzz}", dt); // "-6 -06 -06:00" time zone
Standard Formating Of Date
String.Format("{0:t}", dt); // "4:05 PM" ShortTime
String.Format("{0:d}", dt); // "3/9/2008" ShortDate
String.Format("{0:T}", dt); // "4:05:07 PM" LongTime
String.Format("{0:D}", dt); // "Sunday, March 09, 2008" LongDate
String.Format("{0:f}", dt); // "Sunday, March 09, 2008 4:05 PM" LongDate+ShortTime
String.Format("{0:F}", dt); // "Sunday, March 09, 2008 4:05:07 PM" FullDateTime
String.Format("{0:g}", dt); // "3/9/2008 4:05 PM" ShortDate+ShortTime
String.Format("{0:G}", dt); // "3/9/2008 4:05:07 PM" ShortDate+LongTime
String.Format("{0:m}", dt); // "March 09" MonthDay
String.Format("{0:y}", dt); // "March, 2008" YearMonth
String.Format("{0:r}", dt); // "Sun, 09 Mar 2008 16:05:07 GMT" RFC1123
String.Format("{0:s}", dt); // "2008-03-09T16:05:07" SortableDateTime
String.Format("{0:u}", dt); // "2008-03-09 16:05:07Z" UniversalSortableDateTime
Anandu G NathRank #681 · 3.5K reputationPosted Dec 28, 2023, 2:11 AM EST
using System; using System.Globalization; class Program { static void Main() { int month = 6; // Assuming the integer value for month is 6 (June) int year = 2013; // Assuming the year is 2013 // Creating a DateTime object with the provided month and year DateTime date = new DateTime(year, month, 1); // Day is set to 1 for the first day of the month // Format the DateTime object to display in "MMM-yyyy" format string formattedDate = date.ToString("MMM-yyyy", CultureInfo.InvariantCulture); Console.WriteLine("Formatted Date: " + formattedDate); // Output: Jun-2013 } }@deepa ashwi check this code