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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dayofyear

Status
Not open for further replies.

djack2

Programmer
Dec 12, 2000
16
0
0
US
How do you convert the day of the year, say today which is the 100th day, to the actual date. In this case 04-10-2001.
I have tried a few ways, but there is no way to account for
the year buy looking at just 100. Any thoughts?
 
Wouldn't it be different based on whether the year had leap days in it?

You might be able to ask the user for a year, then try and calculate the date by comapring the value given as DayInYear versus FirstDayOfMonth(CreateDate(<year>,<month>,1).

Something like:

<cfset daysinyear=100>
<cfset currentmonth=1>
<cfloop condition=&quot;daysinmonth less than #DaysInMonth(createdate(year,currentmonth,1)#&quot;>
<cfset daysinyear=daysinyear-#daysInMonth(createdate(year,currentmonth,1)#>
<cfset currentmonth=currentmonth+1>
</cfloop>

The date is #currentmonth#/#daysinyear#/#year#
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top