Skip to main content
Dileep_NR
Inspiring
April 24, 2009
Question

first day of a month

  • April 24, 2009
  • 1 reply
  • 1734 views

Hi All,

     In MYSQL any function is avaliable for get the FIRST DAY OF  a month

/*

LAST_DAY returns last day of the given date. Some thing like this?

*/

Please advice

This topic has been closed for replies.

1 reply

Inspiring
April 24, 2009

In your ColdFusion code, an easy way to get the first day of the month would be along these lines:

<cfscript>

  year = 2009;

  month_number = 4;

  /*

  if you don't want to/can't manually set the year and month you could do this

  today = Now();

  year = Year( today );

  month_number = Month( today );

  */

  first_of_month = CreateDate( year,month_number,1 );

  first_day_of_month = DayOfWeekAsString( first_of_month );

</cfscript>

The variable first_of_month will output April 1, 2009

The variable first_day_of_month will output Wednesday

If you're looking for something more specific to an issue in your application/code, please post some additional examples and details.