
manhattes
Members-
Posts
88 -
Joined
-
Last visited
Everything posted by manhattes
-
Amazing. Thank you.
-
I got it to work by change the my variable to equal $XXX. However, it now duplicates the result if both are found though. Can it only return the $XXX if it is found?
-
I think your first solution is closer to what I need. how would I add the equivalent to "AND Date = '2015-12-4'" ?
-
I have a table with historical pricing info and it is a table that I have to update manually so the most recent date wont always be the current date. Because it may not be updated, I just want the newest entry of Table.Close and another date that is represented in a variable. The above code output: Date 2015-10-16 Close 0.28 seq 2 I need this output and another row which is an exact match to be the output.
-
I have a table of prices by date and I am trying to select two rows, the 2nd row and a fixed row. It the below statement I am trying to get the date less than the current date but it is returning mixed results. How can I get just the row for .$Hist['BuyDateSubmit']. and the row with the date which is on the 2nd row from the top? $HistQ = "select * from TABLE where Date = '".$Hist['BuyDateSubmit']. "' AND (Date <'". $XXX . "' OR Date = '" . $Hist['BuyDateSubmit'] ."')";
-
I am trying to calculate the difference in the previous row using the following query. $query2 = "select * from " . $wsym .",CleanedCalendar where '" . $wsym ."' = CleanedCalendar.Symbol AND " . $wsym .".Close - LAG(" . $wsym .".Close) OVER (ORDER BY " . $wsym .".Date) AS difference FROM " . $wsym .""; I am trying to open two tables and populate a new field called difference. The query works until I add the AND portion of the statement. Is my formatting wrong or am I not allowed to do this? Print: select * from AMDA,CleanedCalendar where 'AMDA' = CleanedCalendar.Symbol AND AMDA.Close - LAG(AMDA.Close) OVER (ORDER BY AMDA.Date) AS difference FROM AMDA 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 'OVER (ORDER BY AMDA.Date) AS difference FROM AMDA' at line 1
-
I am creating a time series and need to dump data there. It is normalized in a master database, but i need to analyze before importing it.
-
I need to store historical data why is this such a crazy thing to do in order to save time? Is it bad to have 300 tables?
-
no i want to create SQL tables.
-
I have a table that has a list of names. 1 name per row. I would like to create a table for each name in the table using the name as the table name. i.e. Table of Names jon bob jess cat creates 4 tables with fields (address, Phone, email,note) table jon table bob table jess table cat Is there a fast way to do this?
-
$queryP="UPDATE table_name SET column1=value1 WHERE some_column=some_value AND some_column=some_value;" $update = mysql_query($queryP) or die(mysql_error()); I dont understand.
-
I would like to save my output of a search into an existing table where two columns match. UPDATE table_name SET column1=value1 WHERE some_column=some_value AND some_column=some_value; Is this possible or do I have to use a join or something?
-
read a cvs file and only displaying some data
manhattes replied to manhattes's topic in PHP Coding Help
I fixed this question. The date format function can only be used on a $date variable so I needed to create it first before using date_format. I know my table isn't uniform but that is also why I use PHP to manipulate the text. Here is the fixed code: $date = date_create($row2['Completion Date']); $newdate = date_format($date, 'Y-m-d'); //echo $newdate; foreach ($file as $value) { if (stristr($value, $newdate)) { // echo $value; Thanks for your help @benanamen. -
read a cvs file and only displaying some data
manhattes replied to manhattes's topic in PHP Coding Help
It is because they are from 2 different sources and each source i add has a different format so I think i need to do it in the code. I am pulling that from my table but I need to match it to a different formatted date. -
read a cvs file and only displaying some data
manhattes replied to manhattes's topic in PHP Coding Help
Yes you are right. $row2['Completion Date'] is stored as Thursday, October 01, 2015 and the format in the csv is y-m-d the column type is varchar -
read a cvs file and only displaying some data
manhattes replied to manhattes's topic in PHP Coding Help
I am still having trouble with the date format. $file = file($url); $newdate = date_format($row2['Completion Date'], 'y-m-d'); echo $newdate; foreach ($file as $value) { if (stristr($value, $newdate)) { echo $value; } } The first and the 5th column i would like. -
read a cvs file and only displaying some data
manhattes replied to manhattes's topic in PHP Coding Help
That almost worked but I think because of the output, the fact the dates are not in the same format is throwing it off. It is also returning the entire row of data: Thursday, October 01, 2015 2011-02-11,5.00,5.09,4.51,4.55,1899700,4.55 Can $value be broken into an array maybe? -
read a cvs file and only displaying some data
manhattes replied to manhattes's topic in PHP Coding Help
This is the output: Date,Open,High,Low,Close,Volume,Adj Close Thanks for your response, i didnt know about that function. I only need it once so I guess it would make more sense to save the entire result to a new table for future reference. -
I am trying to take specific dates out of a csv file. Currently I am able to retrieve and display the data with the following code: $url = "http://ichart.finance.yahoo.com/table.csv?s=" . $row2['Symbol']; echo "<html><body><table border=1>"; $f = fopen($url, "r"); $fr = fread($f, filesize($url)); fclose($f); $ch = curl_init(); $timeout = 30; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); echo $row2['Symbol']; $lines = array(); $lines = explode("\n",$data); for($i=0;$i<count($lines);$i++) { echo "<tr>"; $cells = array(); $cells = explode(",",$lines[$i]); for($k=0;$k<count($cells);$k++) { echo "<td>".$cells[$k]."</td>"; } // for k end echo "</tr>"; } // for i end echo "</table></body></html>"; Can I set the script to only grab dates that are on the first of the month or do I have to create a new table and store the information? I guess I dont understand how I would make a variable to be equal to the date column since it is in a csv file.
-
I already fixed it it. Thank you for the advice..
-
Ok thank you. Sorry I am still missing something. It is saying I have the wrong syntax: $query = "SELECT *, COUNT(Symbol) FROM CleanedCalendar , WHERE `Completion Date` BETWEEN CURDATE() - INTERVAL 90 DAY AND CURDATE() GROUP BY Symbol, `Completion Date` ";
-
yeah I guess it is possible. I am no expert. I am still learning. I am sure my code could be alot cleaner. Do you have any idea as to how to select the date range assuming using the count() assuming the formatting is correct?
-
the `Completion Date` is a field and was imported in a format that SQL doesn't recognize. The string to date allows me to compare it to the current date as I can do with this statement: $query2 = "SELECT * FROM CleanedCalendar WHERE STR_TO_DATE(`Completion Date`, '%W, %M %e, %Y') BETWEEN CURDATE() AND CURDATE() - INTERVAL (90) DAY;";
-
// Setup Variables $query = "SELECT Symbol, `Completion Date`, COUNT(Symbol) FROM CleanedCalendar GROUP BY Symbol,`Completion Date` WHERE STR_TO_DATE(`Completion Date`, '%W, %M %e, %Y') BETWEEN CURDATE() AND CURDATE() + INTERVAL (90) DAY"; $result2 = mysql_query($query) or die(mysql_error()); // Print out result while($row2 = mysql_fetch_array($result2)){ echo "There are ". $row2['COUNT(Symbol)'] ." ". $row2['Symbol'] ." items." . " ". $row2['Completion Date']; echo "<br />"; } there you go. it returns the same result.