Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 11th, 2008, 08:09 AM
Newbie
 
Join Date: Jul 2008
Posts: 20
Default Date data type and manipulation for add and edit through mysql & php

Hi guys,

I have a form in html , all description below:
first: name of persion (input type box)
second: job profile (input type box)
third: experience from: list box (Month : Jan, Feb,.. format) and
experience to: list box (year: 2008,2007,2006,...)

In Mysql database only 4 filed,
1. Name(data type - varchar),
2. Profile(data type - varchar)
3. Experience From, (data type - Date)
4. Experience To :(data type - Date)

I want to store date only month and year month should be first three letter in txt is mondatry (like Jan, Feb,) Means copmlete date format should be like this Jan 2008.

What shold data type and how we manipulate(insert and edit ) ony month year throw php and mysql . The Fom and To field should be date data type mondatory.

pls help me. I'm stuck.
Reply
  #2  
Old August 11th, 2008, 11:05 AM
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 6,870
Default

Try to concatinate the strings and convert to date format before insert into DB.
Reply
  #3  
Old August 11th, 2008, 11:07 AM
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 6,870
Default

Better store the complete date and you can fetch only the month and year part later on as per your requirments.
Reply
  #4  
Old August 11th, 2008, 03:23 PM
Administrator
 
Join Date: Sep 2006
Posts: 11,312
Default

Just use the normal order specified to store the date. The front end should be the one responsible for formatting the date according to the user's preferences.
Reply
  #5  
Old August 11th, 2008, 11:34 PM
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Age: 24
Posts: 5,310
Default

Heya, dkyadav.

Check out PHP's date() (http://php.net/date) and strtotime() (http://php.net/strtotime) functions.
Reply
  #6  
Old August 11th, 2008, 11:38 PM
pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Age: 24
Posts: 5,310
Default

Heya, dkyadav80.

You've been warned about double-posting, and yet you keep doing it.

Your account is now banned for 1 week.

Continued violation of the site Posting Guidelines will result in a PERMANENT ban on your account.

If you have any questions or concerns, feel free to contact me anytime.

Thanks for your time.

pbmods
Reply
  #7  
Old August 12th, 2008, 04:33 AM
cjjer's Avatar
Newbie
 
Join Date: Aug 2008
Posts: 4
Default

you can use date_format format the datetime string:
select date_format(now(), %w %m %y);
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles