![]() |
Inserting Date of Birth into Database
Hello, wonderful helpful people.
I've got a register form, in which people input things like username, password, etc. At the moment, for the date of birth, I've just got it as a regular date field which is really useless as it comes up with a calendar showing the current month and it's gona take everyone ages to find their DOB on that! I would like to have the standard three separate drop downs for day, month, year - but I'm having trouble thinking - would these have to be all separate values inserting into separate columns in my user table in my database? How would I merge them all together so they'd fit into my one DOB column? Should my Access database field be a 'date' type, or just a regular text? Thanks for any light you can shed, it is very much appreciated. |
Quote:
Quote:
|
I've changed that bit of the form into the separate fields, but where am I concatenating the values? I tried it in the destination page by writing
Code:
<CFSET dob = Form.birthday & Form.birthmonth & form.birthyear>Code:
<cfinsert datasource="062105cs06sr" tablename="users" formfields="username,createDate,password,firstname,lastname,#dob#,town,postcode,bio"> |
Hey Suzy. I gotta tell ya, in all my 9 years of ColdFusion development, I have never once used the <cfinsert> tag! I had to look that one up for ya :p lol. Always just used direct querying instead.
But after checking it out, I don't think that it's going to work for you in this case. You might have to write out a full database INSERT statement in a <cfquery> tag. Try this code: Code:
<cfset dob = form.birthMonth & "/" & form.birthDay & "/" & form.birthYear>Hope that helps. -Greg |
yes yes yes! Thank you thank you thank you. :)
|
No problem :) Let me know if you need anything else!
-Greg |
One thing, after you download the date, or upload it, you can extract the month, day and year from your date field. You could even set up the left(Birthday,2) for month, and go to all that trouble. Dates are strored in long binary numbers. You can use date functions like month() day() or year() to extract just that piece of information. But to SEARCH by just the month, the best way I've found, is to explode the date into three separate fields for storing. I have an online history newspaper, as well as a calendar. You can search for any day of the year, or any year, etc. But it sure helps to explode the date. Love the example above using cfqueryparam. I'm spoiled. I like using the CFINSERT tag, which means all my form fields and values must be set prior (not during) inserting them into the database. ... just sayin'
|
| All times are GMT +1. The time now is 08:44 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.