| February (2012) |
| S |
M |
T |
W |
T |
F |
S |
| | | | 1 | 2 | 3 | 4 | | 5 | 6 | 7 | 8 | 9 | 10 | 11 | | 12 | 13 | 14 | 15 | 16 | 17 | 18 | | 19 | 20 | 21 | 22 | 23 | 24 | 25 | | 26 | 27 | 28 |
|
Page Information
These are some development information that I find useful for every day use. I will continue to add information to this page when I find something that I might need to use again. Feel free to use the information on this page!!
Date Reference
| Date Format | MySQL 5.1 | PHP | C# |
| February 3, 2012 | DATE_FORMAT(mydate2, '%M %d, %Y' ) | date('F j, Y') | String.Format("{0:MMMM d, yyyy}", dt); |
| Friday, 2.03.2012 11:50 pm | DATE_FORMAT(mydate2, '%W, %c.%d.%y %h:%i %p' ) | date('l, n.d.Y g:i a') | String.Format("{0:dddd, MMMM d, yyyy h:m t}", dt); |
| 2.03.12 | DATE_FORMAT(mydate2, '%c.%d.%y' ) | date('n.d.y') | String.Format("{0:m.d.yy}", dt); |
| February 3, 2012 11:50 pm | DATE_FORMAT(mydate2, '%M %d, %Y %h:%i %p' ) | date('F j, Y g:i a') | String.Format("{0:MMMM d, yyyy h:m t}", dt); |
| Friday, February 3, 2012 | DATE_FORMAT(mydate2, '%W, %M %d, %Y' ) | date('l, F j, Y') | String.Format("{0:dddd MMMM d, yyyy}", dt); |
SQL Query
This query is useful when you want to query a table and only return the rows within a certain date range. In this case, records created in the past 24 hours will be returned:
select * from sometable
WHERE ChangeDate >= DATEADD(d, - 1, { fn CURDATE() });
In the above query, the "ChangeDate" column is a datetime column type. This query works fine in SQL Server 2000 and 2008.
Powerful PHP SQL Query
Sample of a PHP code that will dump SQL values into an array, sure they might be better ways to do this, but this is simple and I have found to be pretty effective for most cases.
// Get the Value from the Database
$dbquery = "select value,comment from mytable where feature = 'websiteInfo'";
$results = mysql_query($dbquery) or die("Query failed : " . mysql_error());
$dailyfeature = mysql_fetch_array($results, MYSQL_NUM);
$randompdf = $dailyfeature[1];
|