<div>Thanks Carl. This worked for me with schema as datetime.</div>
<div> </div>
<div>Schema used as " 'dob' => array('type' => 'datetime', 'length' => 19, 'default' => '0000-00-00 00:00:00'), " </div>
<div> </div>
<div>If I use schema as date, when I reinstall module, I get error.</div>
<div> </div>
<div>Schema used as " 'dob' => array('type' => 'date', 'length' => 19, 'default' => '0000-00-00'), "</div>
<div> </div>
<div>Am I doing anything wrong with Schema declaration?. </div>
<div> </div>
<div>Error</div>
<div>-------------</div>
<div><em><font color="#ff0000">user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT '0000-00-00', `yrsofexp` INT unsigned NOT NULL DEFAULT 0, `prefworkloc' at line 9 query: CREATE TABLE resubmt_table ( `uid` INT unsigned NOT NULL DEFAULT 0, `name` VARCHAR(64) NOT NULL DEFAULT '', `qualification` VARCHAR(64) NOT NULL DEFAULT '', `email` VARCHAR(64) NOT NULL DEFAULT '', `altemail` VARCHAR(64) NOT NULL DEFAULT '', `phone` VARCHAR(15) NOT NULL DEFAULT '', `altphone` VARCHAR(15) NOT NULL DEFAULT '', `dob` DEFAULT '0000-00-00', `yrsofexp` INT unsigned NOT NULL DEFAULT 0, `prefworkloc` VARCHAR(64) NOT NULL DEFAULT '', INDEX name (name), INDEX yrsofexp (yrsofexp), INDEX prefworkloc (prefworkloc) ) /*!40100 DEFAULT CHARACTER SET utf8 */ in C:\MyWeb6.20\wamp\www\livejobs1\includes\database.inc on line 551.</font></em></div>
<div> </div>
<div> </div>
<div>As such there is no reason for not using Date, Content-profile. I do not know what content-profile does .., I will make use of Date.</div>
<div><br>Regards</div>
<div>Austin.<br></div>
<div class="gmail_quote">On Tue, Mar 29, 2011 at 10:40 AM, Carl Wiedemann <span dir="ltr"><<a href="mailto:carl.wiedemann@gmail.com">carl.wiedemann@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">I assume you're using Drupal 6. See the date_api.module functions like date_make_date() which will return a Date object that can be formatted with date_format_date().
<div><br></div>
<div>Your schema type should be DATETIME or DATE <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html" target="_blank">http://dev.mysql.com/doc/refman/5.0/en/datetime.html</a> </div>
<div><br></div>
<div>You probably want to have something like this to INSERT/UPDATE the db.</div>
<div><br></div>
<div>$date_array['year'] . '-' . $date_array['month'] . '-' . $date_array['day'] . ' 00:00:00';</div>
<div><br></div>
<div>Then, when you SELECT the value you can do something like this.</div>
<div><br></div>
<div>$displayed_date = date_format_date(date_make_date($value, 'UTC'), 'custom', 'm/d/Y');</div>
<div>
<div><br></div>
<div>
<div>Non-language specific strings do not need to be handled with t(), too. :)</div></div>
<div><br></div>
<div>Also, is there a reason you're not using Content Profile with Date module to accomplish your task?</div>
<div><a href="http://drupal.org/project/content_profile" target="_blank">http://drupal.org/project/content_profile</a></div>
<div><a href="http://drupal.org/project/date" target="_blank">http://drupal.org/project/date</a></div>
<div><br></div>
<div><br>
<div class="gmail_quote">
<div>
<div></div>
<div class="h5">On Mon, Mar 28, 2011 at 10:49 PM, Austin Einter <span dir="ltr"><<a href="mailto:austin.einter@gmail.com" target="_blank">austin.einter@gmail.com</a>></span> wrote:<br></div></div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>
<div></div>
<div class="h5">
<div>After all search, I found it really difficult to deal with date. I am trying to store the date in MySql table as varchar type and placeholder as %s.</div>
<div> </div>
<div>However I need two functions to convert date from array format to string format (required while storing into table) and string format to array format (Required while showing it in form).</div>
<div> </div>
<div>The below code does that for me.</div>
<div> </div>
<div> </div>
<div><strong><em>function dateArrToStr(&$customDateArr)<br>{<br> $strDate = t($customDateArr['day']).t('- ').t($customDateArr['month']).t('-') . t($customDateArr['year']);<br> return $strDate;<br>
}</em></strong></div>
<div><strong><em></em></strong> </div>
<div><strong><em></em></strong> </div>
<div><strong><em>function dateStrToArr (&$customDateStr, $length)<br>{<br> $convDate = array();<br> $index = 0;<br> $customToken = t('');<br> $dashPosition = 0;<br> <br> for($index = 0; $index < $length; $index++)<br>
{<br> if($customDateStr[$index] == t('-'))<br> {<br> if($dashPosition == 0)<br> {<br> //Set the day<br> $dashPosition++;<br> $convDate['day'] = $customToken;<br> }<br> else if ($dashPosition == 1)<br>
{<br> //Set the month<br> $dashPosition++;<br> $convDate['month'] = $customToken;<br> }<br> $customToken = t('');<br> }<br> else<br> {<br> $customToken = t($customToken) . t($customDateStr[$index]) ;<br>
}<br> }<br> //Set year<br> $convDate['year'] = $customToken;<br> return $convDate;<br>}</em></strong></div>
<div>
<div></div>
<div>
<div> </div>
<div> </div>
<div>Regards</div>
<div>Austin<br><br></div>
<div class="gmail_quote">On Mon, Mar 28, 2011 at 8:36 AM, Austin Einter <span dir="ltr"><<a href="mailto:austin.einter@gmail.com" target="_blank">austin.einter@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>Hi All</div>
<div>I have a date field in my form.</div>
<div>How do I store/retreive the value into/from MySQL.</div>
<div> </div>
<div>On google search, I saw people are suggesting to use either "int" or "datetime" type.</div>
<div>Please suggest which one needs to be used.</div>
<div> </div>
<div>If I use int (I hope core uses int), while storing can I just store "form['values']['date1']" as %d and while retreivin, what are the related apis to convert back to date.</div>
<div> </div>
<div>Regards</div>
<div>Austin.</div><font color="#888888">
<div> </div>
<div> </div></font></blockquote></div><br></div></div><br></div></div>
<div class="im">--<br>[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br></div></blockquote></div><br></div></div><br>--<br>[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</blockquote></div><br>