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 FormatMySQL 5.1PHPC#
May 25, 2013DATE_FORMAT(mydate2, '%M %d, %Y' ) date('F j, Y')String.Format("{0:MMMM d, yyyy}", dt);
Saturday, 5.25.2013 11:20 pmDATE_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);
5.25.13DATE_FORMAT(mydate2, '%c.%d.%y' ) date('n.d.y')String.Format("{0:m.d.yy}", dt);
May 25, 2013 11:20 pmDATE_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);
Saturday, May 25, 2013DATE_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];

Privacy Policy