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!

Date to String to form select 1

Status
Not open for further replies.

DerAdi

Programmer
Aug 31, 2005
8
AU
Hi all,

I'm working on a site for a art gallery. They'll publish their exhibitons through a CMS.
I created a form that has three select (drop down) fields: day, month and year. Writing it into the database was easy enough (connect to a string with / as denominator and then use the dateformat in the insert sql code.
Now, they'll also be able to edit an existing exhibition, which means I'll have to display the opening date in the same manner. I'm a bit stuck now. How do I take the date format from the DB and split it into the three strings that I need (will use <cfif #openingDay# EQ 1> selected</cfif>, etc.).

Any recommendations, hints, codes for this?

Thanks a lot.
Adrian
 
Code:
select year(openingdate) as openingYear
     , month(openingdate) as openingMOnrg
     , day(openingdate) as openingDay
     , othercolumns
  from yourtable
 where ...
whether the YEAR(), MONTH(), DAY() functions will actually work depends on which database you're using, which you neglected to mention




r937.com | rudy.ca
 
I'm using a MS Access DB on this small project.

I was a bit trigger happy on this post, sorry. Figured out a way myself. Did it different though:

<cfset dateOpensDay = #day(exhibitionDetail.exhibtionOpensDate)#>
<cfset dateOpensMonth = #month(exhibitionDetail.exhibtionOpensDate)#>
<cfset dateOpensYear = #year(exhibitionDetail.exhibtionOpensDate)#>

Does the setting of the variables instead of selecting it in the sql statement have any consequences?

Thanks though r937.

Adrian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top