Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>SQLite doesn't have Date/Time data types (<a href="http://www.sqlite.org/datatype3.html" rel="nofollow">http://www.sqlite.org/datatype3.html</a>), so the " usual SQL format of YYYY-MM-DD" isn't the usual, in this case. </p> <p>There are several date time functions (<a href="http://www.sqlite.org/lang_datefunc.html" rel="nofollow">http://www.sqlite.org/lang_datefunc.html</a>) but you can avoid those, most of the time, by just using the INTEGER data type on your date/time column and storing the epoch stamp (<a href="http://en.wikipedia.org/wiki/Unix_time" rel="nofollow">http://en.wikipedia.org/wiki/Unix_time</a>). </p> <p><code>DatePicker</code> returns separate values for year/month/day of month, and month is zero-indexed. This is because it's intended to work with <code>Calendar</code> (as evil as that may be). So with an INTEGER column, and something like this, you can store and retrieve date/times fine:</p> <pre><code>Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, datePicker.getYear()); cal.set(Calendar.MONTH, datePicker.getMonth()); cal.set(Calendar.DAY_OF_MONTH, datePicker.getDayOfMonth()); long datePubStamp = cal.getTimeInMillis(); </code></pre> <p>Then store the datePubStamp in the INTEGER column. </p> <p>To restore a <code>Calendar</code> just use <code>Calendar.setTimeInMillis(&lt;value_from_integer_db_column&gt;)</code>. And, you can of course get a <code>Date</code> from a <code>Calendar</code> with <code>getTime()</code>, and then format with <code>SimpleDateFormat</code>, etc. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload