Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FirstDayOfMonth function shown y2k problem 1

Status
Not open for further replies.

xzhang

Programmer
Jun 7, 2001
9
0
0
US
Hi,

We use Coldfusion Server 4.5 on Unix. The following code
produced unexpected date:

<cfoutput>
#DateFormat(now()-1,&quot;mm/dd/yyyy&quot;)#<br>
#DateFormat(FirstDayOfMonth('01/01/1900'),&quot;mm/dd/yyyy&quot;)#<br>
#DateFormat(FirstDayOfMonth('01/01/1950'),&quot;mm/dd/yyyy&quot;)#<br>
#DateFormat(FirstDayOfMonth('01/01/1999'),&quot;mm/dd/yyyy&quot;)#<br>
#DateFormat(FirstDayOfMonth('01/01/2000'),&quot;mm/dd/yyyy&quot;)#<br>
#DateFormat(FirstDayOfMonth('01/01/2001'),&quot;mm/dd/yyyy&quot;)#<br>
</cfoutput>

output on IE:

06/19/2001
12/31/1899
12/31/1899
12/31/1899
12/31/1899
12/31/1899

Have you any solution for that problem?

Thanks.

Xiaoming
 
you can't specify a date format of dd/mm/yyyy for a firstdayofmonth, firstdayofmonth returns the day of the year i.e. 1st January 2001 = day no. 1, 1st Feburary 2001 = day no. 32 being 31 days in jan + 1st day in feb..
if you try and dateformat a number like 32 then it doesn't like it and gives you 12/31/1899!

To convert the day no. i.e. 32 into a day of week then use the following:

DayOfWeekAsString(DayOfWeek(FirstDayOfMonth(Now())))

replacing now() with whatever date you want... when using two digit years remember that years from 0 to 29 are interpreted as 21st century values. Years 30 to 99 are interpreted as 20th century values.

Hope this helps,

Al
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top