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

date display

Status
Not open for further replies.

izachar

Technical User
Oct 7, 2000
84
CA
I used one of the advices from Kyrene and it was great. It allowed me to create drop down menues for dates. I stored them in the db but now when the user wants to edit the date I want to display it as the default values in the form. I tried:

<cfquery datasource=&quot;centrefund&quot; name=&quot;ed_pr&quot;>
select pr_id,pr_date....
from press_release
where pr_id='#pr_id#'
</cfquery>

<cfset d=day(#pr_date#)>
<cfset m=month(#pr_date#)>
<cfset y=year(#pr_date#)>

and then down later I tried

<select name=&quot;month&quot;>
<cfloop index=&quot;m&quot; from=1 to=12>
<option value=&quot;#m#&quot;>#monthasstring(m)#
</cfloop>
</select>
<select name=&quot;day&quot;>
<cfloop index=&quot;d&quot; from=1 to=31>
<option value=&quot;#d#&quot;>#d#</option>
</cfloop>
</select>
<select name=&quot;year&quot;>
<cfloop index=&quot;y&quot; from=2000 to=2005>
<option value=&quot;#y#&quot;>#y#
</cfloop>
</select>

Thanks in advance
 
Hi, izachar!

Is this what you are looking for? FYI, ServiceLastModified is an OBDC Date/Time object.
Code:
<CFSET CurrentDay=DAY(#GETDATE.SERVICELASTMODIFIED#)>
<CFSET CurrentMonth=MONTH(#GETDATE.SERVICELASTMODIFIED#)>
<CFSET CurrentYear=YEAR(#GETDATE.SERVICELASTMODIFIED#)> 

<CFOUTPUT>
<FORM ACTION=&quot;#CGI.SCRIPT_NAME#&quot; METHOD=&quot;post&quot;>
<SELECT NAME=&quot;month&quot;>
   <CFLOOP INDEX=&quot;m&quot; FROM=1 TO=12>
    <OPTION VALUE=&quot;#m#&quot;<CFIF CURRENTMONTH IS M> selected=&quot;yes&quot;</CFIF>>#monthasstring(m)#
     </CFLOOP>
</SELECT>
<SELECT NAME=&quot;day&quot;>
   <CFLOOP INDEX=&quot;d&quot; FROM=1 TO=31>
    <OPTION VALUE=&quot;#d#&quot;<CFIF CURRENTDAY IS D> selected=&quot;yes&quot;</CFIF>>#d#</OPTION>
     </CFLOOP>
</SELECT>
<SELECT NAME=&quot;year&quot;>
   <CFLOOP INDEX=&quot;y&quot; FROM=2000 TO=2005>
    <OPTION VALUE=&quot;#y#&quot;<CFIF CURRENTYEAR IS Y> selected=&quot;yes&quot;</CFIF>>#y#
     </CFLOOP>
</SELECT>
</FORM>
</CFOUTPUT>
Calista :-X
Jedi Knight,
Champion of the Force
 
Thanks but I am getting an error:
An error occurred while evaluating the expression:
CurrentDay=DAY(#GETDATE.SERVICELASTMODIFIED#)
My date/time field is stored in the pr_date column. I tried to replace it the servicelastmodified with pr_date but it did not work. Any ideas?

 
You need to refer to the name of your query when you refer to your date variable.
Either:
Code:
<CFSET CurrentDay=&quot;#DAY(ed_pr.pr_date)#&quot;>
or:
Code:
<CFOUTPUT QUERY=&quot;ed_pr&quot;><CFSET CurrentDay=&quot;#DAY(pr_date)#&quot;></CFOUTPUT>

Also, my syntax was a little off, but it still worked. Here it is in the correct form:
Code:
<CFSET Date_Today=&quot;#CreateODBCDate(Now())#&quot;>
<CFSET CurrentDay=&quot;#DAY(Date_Today)#&quot;>
<CFSET CurrentMonth=&quot;#MONTH(Date_Today)#&quot;>
<CFSET CurrentYear=&quot;#YEAR(Date_Today)#&quot;> 

<CFOUTPUT>
<FORM ACTION=&quot;#CGI.SCRIPT_NAME#&quot; METHOD=&quot;post&quot;>
<SELECT NAME=&quot;month&quot;>
   <CFLOOP INDEX=&quot;m&quot; FROM=1 TO=12>
    <OPTION VALUE=&quot;#m#&quot;<CFIF CURRENTMONTH IS M> selected=&quot;yes&quot;</CFIF>>#monthasstring(m)#
     </CFLOOP>
</SELECT>
<SELECT NAME=&quot;day&quot;>
   <CFLOOP INDEX=&quot;d&quot; FROM=1 TO=31>
    <OPTION VALUE=&quot;#d#&quot;<CFIF CURRENTDAY IS D> selected=&quot;yes&quot;</CFIF>>#d#</OPTION>
     </CFLOOP>
</SELECT>
<SELECT NAME=&quot;year&quot;>
   <CFLOOP INDEX=&quot;y&quot; FROM=2000 TO=2005>
    <OPTION VALUE=&quot;#y#&quot;<CFIF CURRENTYEAR IS Y> selected=&quot;yes&quot;</CFIF>>#y#
     </CFLOOP>
</SELECT>
</FORM>
</CFOUTPUT>
Calista :-X
Jedi Knight,
Champion of the Force
 
Thank you very much it worked great. I was not familiar with naming the query out of the cfoutput tag. Very helpfull.

thank you again
 
No problem. Glad I could help! Calista :-X
Jedi Knight,
Champion of the Force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top