//Assuming that the field name is Bdate
convert (varchar,(select DateName(month,dateadd(month,month(Bdate),0)-1)),103)
August 1, 2009 at 11:57 am (sqlserver-2005)
Tags: date field, get month name, monthname, stored procedure
//Assuming that the field name is Bdate
convert (varchar,(select DateName(month,dateadd(month,month(Bdate),0)-1)),103)
August 1, 2009 at 11:14 am (ASP.NET)
Tags: asp.net, current month, get current month from current date, monthname
There are two ways to get the Current Month Name from the Current Date.
1) Using Globliziation
System.Globalization.DateTimeFormatInfo d = new System.Globalization.DateTimeFormatInfo();
string month = d.MonthNames[DateTime.Now.Month-1];2) Using new date object as follow
string MonthName = GetMonthName(DateTime.Now.Month);
static string GetMonthName(int monthNum)
{
return GetMonthName(monthNum, false);
}
static string GetMonthName(int monthNum, bool abbreviate)
{
if (monthNum < 1 || monthNum > 12)
throw new ArgumentOutOfRangeException(”monthNum”);
DateTime date = new DateTime(1, monthNum, 1);
if (abbreviate)
return date.ToString(”MMM”);
else
return date.ToString(”MMMM”);
}
August 1, 2009 at 10:10 am (sqlserver-2005)
Tags: asp.net, birthday, find date in current month, stored procedure
//Assuming the table name as Users and fieldname as Bdate
select * from Users
where month(Bdate)=month(getdate())
and day(Bdate)between Day(getdate())
and day(dateadd(day,30,getdate()))