Note that there are some explanatory texts on larger screens.

plurals
  1. POretrieving date in SELECT statement from mysql
    primarykey
    data
    text
    <p>I wrote the following mysql code:</p> <pre><code>select trade_dt, ticker_id, settle_price, volume from hist where volume &gt; 0 and trade_dt between '06/22/2011' and '06/30/2011'; </code></pre> <p>but unfortunately, it returns dates outside the time window as follows:</p> <pre><code>+------------+------------+--------------+--------+ | trade_dt | ticker_id | settle_price | volume | +------------+------------+--------------+--------+ | 06/23/2006 | N (Jul 06) | 156.900000 | 90 | | 06/26/2006 | N (Jul 06) | 155.600000 | 63 | | 06/27/2006 | N (Jul 06) | 159.300000 | 79 | | 06/28/2006 | N (Jul 06) | 159.600000 | 57 | | 06/29/2006 | N (Jul 06) | 143.400000 | 511 | | 06/30/2006 | N (Jul 06) | 140.200000 | 342 | | 06/23/2005 | V (Oct 05) | 151.200000 | 61 | | 06/23/2011 | U (Sep 11) | 22.500000 | 6284 | | 06/24/2011 | U (Sep 11) | 23.100000 | 4505 | | 06/27/2011 | U (Sep 11) | 22.650000 | 3118 | | 06/28/2011 | U (Sep 11) | 22.100000 | 3707 | | 06/29/2011 | U (Sep 11) | 21.500000 | 5830 | | 06/30/2011 | U (Sep 11) | 20.750000 | 9207 | | 06/23/2008 | F (Jan 09) | 23.260000 | 2 | </code></pre> <p>and I wonder if that is because my trade_dt is defined as a string in hist table.EDITED table to replace char(10) with date</p> <pre><code>desc hist; +-----------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------------+------+-----+---------+----------------+ | futures_id | int(11) | NO | PRI | NULL | auto_increment | | trade_dt | date | NO | | NULL | | | ticker_id | varchar(46) | NO | MUL | NULL | | | settle_price | decimal(10,6) | NO | | NULL | | | change_in_price | decimal(10,6) | NO | | NULL | | | volume | bigint(11) | NO | | NULL | | | open_int | bigint(11) | NO | | NULL | | +-----------------+---------------+------+-----+---------+----------------+ </code></pre> <p>how do I fix my date problem?</p> <p>ok, I changed the <code>trade_dt</code> field to <code>date</code> instead of <code>char(10)</code> and now when I run the below statement to load the data into the DB, it inserts blanks for dates, just because how the date is formatted in the data file.</p> <pre><code>LOAD DATA LOCAL INFILE '$fn' INTO TABLE $tn FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' (trade_dt,ticker_id,settle_price,change_in_price, volume, open_int); </code></pre> <p>this is a sample of raw data:</p> <pre><code>03/30/2012,Z (Dec 12),25.81,25.81,25.50,25.70,25.60,-0.45,24,0,318 </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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