If you are storing birthdates, you probably want to use DATETIME in the schema instead of INT. INT would require the date be stored as a unix timestamp, which is only valid after the year 1970, and birthdays are likely to exist before this date.<div>
<br></div><div>DATETIME accepts strings formatted like </div><div><br></div><div>YYYY-MM-DD HH:MM:SS</div><div><br></div><div>and generally you store the UTC date and convert the timezone later.</div><div><br></div><div>See some of the functions in the Date API module for help in conversion (comes with Date module). Some of these utilities have been moved into core in Drupal 7.<br>
<div><div><br clear="all"><div><br></div><div class="gmail_quote">On Mon, Mar 28, 2011 at 9:27 AM, Brett Evanson <span dir="ltr">&lt;<a href="mailto:brettev@gmail.com">brettev@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
You might want to look at the strtotime function in php. I believe it<br>
would take that date and turn it into a Unix epoch number (i think<br>
that&#39;s what you&#39;re looking for)<br>
<br>
Brett Evanson<br>
<div><div></div><div class="h5"><br>
<br>
<br>
<br>
<br>
On Mon, Mar 28, 2011 at 9:15 AM, Austin Einter &lt;<a href="mailto:austin.einter@gmail.com">austin.einter@gmail.com</a>&gt; wrote:<br>
&gt; Hi All<br>
&gt; I have date field, I am storing it as &quot;int&quot; in table.<br>
&gt; When I checked the table in database, the value shows as 1.<br>
&gt;<br>
&gt; My code is as below.<br>
&gt;<br>
&gt; &#39;INSERT INTO {rs_table} ( uid, name, qualification, email, altemail, phone,<br>
&gt; altphone, dob, yrsofexp, prefworkloc) &#39;<br>
&gt;       .&quot;VALUES (%d, &#39;%s&#39;, &#39;%s&#39;, &#39;%s&#39;, &#39;%s&#39;, &#39;%s&#39;, &#39;%s&#39;, &#39;%d&#39;, &#39;%d&#39;, &#39;%s&#39;)&quot;,<br>
&gt;      $user-&gt;uid,<br>
&gt;      $form_state[&#39;values&#39;][&#39;persname&#39;],<br>
&gt;      $form_state[&#39;values&#39;][&#39;hqualif&#39;],<br>
&gt;      $form_state[&#39;values&#39;][&#39;email&#39;],<br>
&gt;      $form_state[&#39;values&#39;][&#39;altemail&#39;],<br>
&gt;      $form_state[&#39;values&#39;][&#39;phone&#39;],<br>
&gt;      $form_state[&#39;values&#39;][&#39;altphone&#39;],<br>
&gt;     $form_state[&#39;values&#39;][&#39;birthdate&#39;],<br>
&gt;     $form_state[&#39;values&#39;][&#39;yearsexp&#39;],<br>
&gt;     $form_state[&#39;values&#39;][&#39;prefloc&#39;]<br>
&gt;   );<br>
&gt;<br>
&gt; Whats the wrong here, is there any API I have to make use of to convert from<br>
&gt; date to int value??<br>
&gt;<br>
&gt; Regards<br>
&gt; Austin<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Mar 28, 2011 at 8:36 AM, Austin Einter &lt;<a href="mailto:austin.einter@gmail.com">austin.einter@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi All<br>
&gt;&gt; I have a date field in my form.<br>
&gt;&gt; How do I store/retreive the value into/from MySQL.<br>
&gt;&gt;<br>
&gt;&gt; On google search, I saw people are suggesting to use either &quot;int&quot; or<br>
&gt;&gt; &quot;datetime&quot; type.<br>
&gt;&gt; Please suggest which one needs to be used.<br>
&gt;&gt;<br>
&gt;&gt; If I use int (I hope core uses int), while storing can I just<br>
&gt;&gt; store &quot;form[&#39;values&#39;][&#39;date1&#39;]&quot; as %d and while retreivin, what are the<br>
&gt;&gt; related apis to convert back to date.<br>
&gt;&gt;<br>
&gt;&gt; Regards<br>
&gt;&gt; Austin.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
</div></div>&gt; --<br>
&gt; [ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
&gt;<br>
<font color="#888888">--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</font></blockquote></div><br></div></div></div>