MySQL Date_Format

Hi
Can anyone tell me how they'd format this MySQL statement to read dates stored in MySQL?  The dates are pre-1970 so I'm having trouble using PHP echo date.
$query_rsGNresults = sprintf("SELECT * FROM gemnews_tab WHERE language LIKE %s AND entry LIKE %s AND works LIKE %s AND category LIKE %s ORDER BY date ASC;", GetSQLValueString($varLang_rsGNresults, "text"),GetSQLValueString($varEntry_rsGNresults, "text"),GetSQLValueString($varWorks_rsGNresults, "text"),GetSQLValueString($varCategory_rsGNresults, "text"));
I've tried
$query_rsGNresults = sprintf("SELECT * DATE_FORMAT(date, '%Y %M %d') FROM gemnews_tab WHERE language LIKE %s AND entry LIKE %s AND works LIKE %s AND category LIKE %s ;", GetSQLValueString($varLang_rsGNresults, "text"),GetSQLValueString($varEntry_rsGNresults, "text"),GetSQLValueString($varWorks_rsGNresults, "text"),GetSQLValueString($varCategory_rsGNresults, "text"));
but all I get is a sprintf error that there are too few arguments.
Any help is greatly appreciated.
Many thanks
J

Hello Mad Dog,
I am sorry that you have not received a response for the
WebAssist
community forums.
The most effective way to get your issue addressed is by
submitting a
Technical Support Incident (PSI) because we have a policy to
provide you
with a response within 2-4 business hours. We include a
number of
Support Incidents for free with each product
If you would like to submit one go to
http://www.webassist.com/ and
click on the Support link on the gray bar above the Product
Spotlight.
On the Support page, choose Support > Technical Support
> Submit
Incident. Select your product and click on the appropriate
radio button
that applies to the nature of your product. Click Next and
fill out the
form on the subsequent page. An engineer should reply back to
you within
2 to 4 hours.
Feel free to contact me off list if you have further
questions.
Regards,
Mark
Mark Fletcher
WebAssist.com
Mad Dog wrote:
> On recommendation of a few people here (yes, Murray, I
do listen to you
> sometimes!) I picked up DataAssist from WebAssist to
create a front-end
> database admin area for a client. Easily worth the money
since it saved me
> hours of gunky work creating one myself and the client
will be paying for
> it. One question though -- and yes, I've posted it on
the WebAssist forum
> but haven't had a response yet:
>
> - It's unwieldy to ask whoever's entering the data to
input the date as
> YYYY-MM-DD when no one thinks that way. Is there a way
to have them input it
> in US style (MM-DD-YYYY) and have it converted? It would
be a nice function
> to have built-in but since it's not, is there an
**easy** way to implement
> this?
>
> Thanks,
> Mad Dog
>
>

Similar Messages

  • Formatting mySQL date in a dynamic field

    Hi all.. I've seen many articles on here about how to INSERT dates to the mySQL table, but I need to know how to format it into MM/DD/YYYY when the form dynamically populates from an existing record.  Just using a regular DW8 Recordset behavior for this...
    Thanks-

    AdrianLe wrote:
    I need to know how to format it into MM/DD/YYYY when the form dynamically populates from an existing record.
    Use the MySQL DATE_FORMAT() function and assign the result to an alias in your SQL.
    For example, let's say you have a date stored in a field called start. The following would format the date in your desired format, and present it in the recordset results as start_date:
    SELECT DATE_FORMAT(start, '%m/%d/%Y') AS start_date,
    another_field, yet_another
    FROM my_table
    There's a full list of the formatting characters in the MySQL reference manual (follow the link above).

  • Timestamp phpmyadmin in dreamweaver

    Working with phpMyAdmin, I've got a table called news
    with a field called time
    and type timestamp (standard value: current_timestamp; on update current_timestamp)
    Now using dreamweaver, I insert the following code to show the time field on a page:
    <?php echo $row_news ['time']; ?>
    which returns something like 2009-04-20 14:54:02 this for example, though always in this format (0000-00-00 00:00:00)
    Since I'm European, this way of time notation is 'weird' to say the least. I would prefer to see it be written like this 20-04-2009 14u54
    It's really 'annoying' me because I can't find a way around this myself and I've googled my *** off on this matter. Anyone any suggestions?

    MySQL always stores dates in the ISO recommended format, YYYY-MM-DD HH:MM:SS. This avoids all the annoyances of trying to work out whether the date was entered by an American, a European, or an East Asian, all of whom use different ways to display date and time.
    So, how do you display the date and time in your own preferred format? Simple. Use the MySQL DATE_FORMAT() function, and assign the result to an alias using the AS keyword. Details of DATE_FORMAT() and all other date/time functions are in the MySQL documentation at http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html.
    To display the date in your preferred format, use the following SQL:
    SELECT column1, column2,
    DATE_FORMAT(time, '%d-%m-%Y %ku%S') AS formatted_time
    FROM myTable
    You can then retrieve this as part of your recordset as $row_new['formatted_time'].
    The formatting character specifiers are all listed in the MySQL page that I referred to earlier. In my example, column1, column2 represent other columns (fields that you want to retrieve from the database in your SQL query.

  • Converting timestamp to dd-mm-yy

    Hi
    does anyone know how to convert a unix timestamp to readable
    dd-mm-yy format? ive tried using the date_format function in SQL
    but that doesnt work?
    anyone have any ideas?
    the field "created" is the timestamp.
    thanks

    Kamesh192 wrote:
    > does anyone know how to convert a unix timestamp to
    readable dd-mm-yy format?
    > ive tried using the date_format function in SQL but that
    doesnt work?
    The MySQL DATE_FORMAT() function is for use with ISO dates
    (YYYY-MM-DD)
    only. To convert a Unix timestamp to a readable format, use
    FROM_UNIXTIME().
    "SELECT node.title, FROM_UNIXTIME(node.created, '%F %d %Y')
    as new_time ,
    node_revisions.body FROM node INNER JOIN node_revisions ON
    node.nid =
    node_revisions.nid WHERE node.type='story' ORDER BY node.nid
    desc limit 1"
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Error In MySQL Query With DATE_FORMAT

    this produses an empty query when it shouldn't. I've made some error when using DATE_FORMAT and filtering by MONTH and YEAR but not sure how to fix it:
    mysql_select_db($database_VALUATIONS, $VALUATIONS);
    $query_valuations = sprintf("SELECT val_Trans_id, DATE_FORMAT(val_Date '%d-%m-%Y'), val_Company_Name, val_Company_Ref, val_Manufacturer, val_Model FROM valuations WHERE val_Company_Ref = %s AND MONTH(val_Date) =  %s AND YEAR(val_Date) =  %s ORDER BY val_Date DESC", GetSQLValueString($colname_valuations, "text"),GetSQLValueString($colname2_valuations, "text"),GetSQLValueString($colname3_valuations, "text"));
    Thanks if anyone knows the answer ......

    I think that works as you say but I still can't get it to work with WHERE clauses for month and year, this tst works:
    <?php require_once('Connections/tallon_admin.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    mysql_select_db($database_tallon_admin, $tallon_admin);
    $query_Recordset1 = "SELECT DATE_FORMAT(val_Date, '%d-%m-%Y') as Date, val_Company_Name FROM valuations";
    $Recordset1 = mysql_query($query_Recordset1, $tallon_admin) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Web Site</title>
    </head>
    <body>
    <?php echo $row_Recordset1['Date']; ?> <br>
    <br>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    mysql_free_result($mysql);
    ?>
    I just can't get it working with a where clause to filter by month, this example returns an empty query when it shouldn't - also tried MONTH(val_Date) = %s
    <?php require_once('Connections/tallon_admin.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $colname_Recordset1 = "-1";
    if (isset($_GET['month'])) {
      $colname_Recordset1 = $_GET['month'];
    mysql_select_db($database_tallon_admin, $tallon_admin);
    $query_Recordset1 = sprintf("SELECT DATE_FORMAT(val_Date, '%d-%m-%Y') as Date, val_Company_Name FROM valuations WHERE MONTH(Date) = %s", GetSQLValueString($colname_Recordset1, "date"));
    $Recordset1 = mysql_query($query_Recordset1, $tallon_admin) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Web Site</title>
    </head>
    <body>
    <?php echo $row_Recordset1['Date']; ?> <br>
    <br>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    mysql_free_result($mysql);
    ?>

  • How to show/hide div based on mysql value

    I have a dataset that has a column 'locked' that is a boolean that I want to use to remove a button on a form.  The idea being that it will be set to 1 after a period of time thus removing the buttun that links to an update form and preventing the data from being changed.  Currently, I have the field linked to a check box at the top of the table.  How do I use this to hide the button (or any other html element for that matter) when set to 1 and show the element when set to 0?  I understand I need to creat a php variable from the mysql boolean and then use a if/else loop to hide/display the html but I don't know how to impliment this?  Thanks for any help offered.
    Here's the code:
    <?php require_once('Connections/testmypms.php'); ?>
    <?php
    $currentPage = $_SERVER["PHP_SELF"];
    $maxRows_spec_rx = 10;
    $pageNum_spec_rx = 0;
    if (isset($_GET['pageNum_spec_rx'])) {
      $pageNum_spec_rx = $_GET['pageNum_spec_rx'];
    $startRow_spec_rx = $pageNum_spec_rx * $maxRows_spec_rx;
    $colname_spec_rx = "1";
    if (isset($_GET['pxID'])) {
      $colname_spec_rx = (get_magic_quotes_gpc()) ? $_GET['pxID'] : addslashes($_GET['pxID']);
    mysql_select_db($database_testmypms, $testmypms);
    $query_spec_rx = sprintf("SELECT spec_rx.spec_rx_id, spec_rx.FK_px_id, DATE_FORMAT(spec_rx.spec_rx_date, '%%d-%%m-%%Y') as formatted_rx_date, spec_rx.FK_user_id, spec_rx.spec_rx_rsph, spec_rx.spec_rx_rcyl, spec_rx.spec_rx_raxis, spec_rx.spec_rx_rhprism, spec_rx.spec_rx_rhprismbase, spec_rx.spec_rx_rvprism, spec_rx.spec_rx_rvprismbase, spec_rx.spec_rx_rnadd, spec_rx.spec_rx_rnhprism, spec_rx.spec_rx_rnhprismbase, spec_rx.spec_rx_rnvprism, spec_rx.spec_rx_rnvprismbase, spec_rx.spec_rx_rintadd, spec_rx.spec_rx_rinthprism, spec_rx.spec_rx_rinthprismbase, spec_rx.spec_rx_rintvprism, spec_rx.spec_rx_rintvprismbase, spec_rx.spec_rx_lsph, spec_rx.spec_rx_lcyl, spec_rx.spec_rx_laxis, spec_rx.spec_rx_lhprism, spec_rx.spec_rx_lhprismbase, spec_rx.spec_rx_lvprism, spec_rx.spec_rx_lvprismbase, spec_rx.spec_rx_lintadd, spec_rx.spec_rx_linthprism, spec_rx.spec_rx_linthprismbase, spec_rx.spec_rx_lintvprism, spec_rx.spec_rx_lintvprismbase, spec_rx.spec_rx_lnadd, spec_rx.spec_rx_lnhprism, spec_rx.spec_rx_lnhprismbase, spec_rx.spec_rx_lnvprism, spec_rx.spec_rx_lnvprismbase, spec_rx.locked, users.user_id, users.user_firstname, users.user_surname FROM spec_rx, users WHERE %s = spec_rx.FK_px_id AND spec_rx.FK_user_id = users.user_id ORDER BY spec_rx.spec_rx_date DESC, spec_rx.spec_rx_id DESC", $colname_spec_rx);
    $query_limit_spec_rx = sprintf("%s LIMIT %d, %d", $query_spec_rx, $startRow_spec_rx, $maxRows_spec_rx);
    $spec_rx = mysql_query($query_limit_spec_rx, $testmypms) or die(mysql_error());
    $row_spec_rx = mysql_fetch_assoc($spec_rx);
    if (isset($_GET['totalRows_spec_rx'])) {
      $totalRows_spec_rx = $_GET['totalRows_spec_rx'];
    } else {
      $all_spec_rx = mysql_query($query_spec_rx);
      $totalRows_spec_rx = mysql_num_rows($all_spec_rx);
    $totalPages_spec_rx = ceil($totalRows_spec_rx/$maxRows_spec_rx)-1;
    $colname_demographics = "1";
    if (isset($_GET['pxID'])) {
      $colname_demographics = (get_magic_quotes_gpc()) ? $_GET['pxID'] : addslashes($_GET['pxID']);
    mysql_select_db($database_testmypms, $testmypms);
    $query_demographics = sprintf("SELECT demographics.px_id, demographics.FK_title_id, demographics.firstname, demographics.surname, DATE_FORMAT(demographics.dob, '%%d-%%m-%%Y') as formatted_dob, title.title_id, title.title FROM demographics, title WHERE %s = demographics.px_id AND demographics.FK_title_id = title.title_id", $colname_demographics);
    $demographics = mysql_query($query_demographics, $testmypms) or die(mysql_error());
    $row_demographics = mysql_fetch_assoc($demographics);
    $totalRows_demographics = mysql_num_rows($demographics);
    $queryString_spec_rx = "";
    if (!empty($_SERVER['QUERY_STRING'])) {
      $params = explode("&", $_SERVER['QUERY_STRING']);
      $newParams = array();
      foreach ($params as $param) {
        if (stristr($param, "pageNum_spec_rx") == false &&
            stristr($param, "totalRows_spec_rx") == false) {
          array_push($newParams, $param);
      if (count($newParams) != 0) {
        $queryString_spec_rx = "&" . htmlentities(implode("&", $newParams));
    $queryString_spec_rx = sprintf("&totalRows_spec_rx=%d%s", $totalRows_spec_rx, $queryString_spec_rx);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Spec Rx3</title>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_goToURL() { //v3.0
      var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
      for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
    //-->
    </script>
    </head>
    <body>
    <p>Spec Rx</p>
    <p><?php echo $row_demographics['px_id']; ?></p>
    <p><?php echo $row_demographics['title']; ?> <?php echo $row_demographics['firstname']; ?> <?php echo $row_demographics['surname']; ?> <?php echo $row_demographics['formatted_dob']; ?> </p>
    <p>
      <input name="Add_spec_rx" type="button" id="Add_spec_rx" onClick="MM_goToURL('parent','add_spec_rx.php');return document.MM_returnValue" value="New Rx">
    </p>
    <p> <a href="<?php printf("%s?pageNum_spec_rx=%d%s", $currentPage, max(0, $pageNum_spec_rx - 1), $queryString_spec_rx); ?>">Previous</a> <a href="<?php printf("%s?pageNum_spec_rx=%d%s", $currentPage, min($totalPages_spec_rx, $pageNum_spec_rx + 1), $queryString_spec_rx); ?>">Next</a></p>
    <?php do { ?>
    <table border="1" cellspacing="1" cellpadding="5">
      <tr>
        <td> </td>
        <td><?php echo $row_spec_rx['formatted_rx_date']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_id']; ?></td>
        <td>locked:
        <input <?php if (!(strcmp($row_spec_rx['locked'],1))) {echo "checked";} ?> name="locked" type="checkbox" id="locked" value="1"></td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td>Sph</td>
        <td>Cyl</td>
        <td>Axis</td>
        <td>HPrism</td>
        <td>HPrismBase</td>
        <td>VPrism</td>
        <td>VPrismBase</td>
        <td>NrAdd</td>
        <td>NrHPrism </td>
        <td>NrHPrismBase</td>
        <td>NrVPrism</td>
        <td>NrVPrismBase</td>
        <td>IntAdd</td>
        <td>IntHPrism</td>
        <td>IntHPrismBase</td>
        <td>IntVPrism</td>
        <td>IntVPrismBase</td>
      </tr>
      <tr>
        <td>R</td>
        <td><?php echo ($row_spec_rx['spec_rx_rsph']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_rsph']) : null; ?></td>
        <td><?php echo ($row_spec_rx['spec_rx_rcyl']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_rcyl']) : null; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_raxis']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rnvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rintadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rinthprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rinthprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rintvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_rintvprismbase']; ?></td>
      </tr>
      <tr>
        <td>L</td>
        <td><?php echo ($row_spec_rx['spec_rx_lsph']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_lsph']) : null; ?></td>
        <td><?php echo ($row_spec_rx['spec_rx_lcyl']<>null) ? sprintf ("%+4.2f",$row_spec_rx['spec_rx_lcyl']) : null; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_laxis']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnhprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnhprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lnvprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lintadd']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_linthprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_linthprismbase']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lintvprism']; ?></td>
        <td><?php echo $row_spec_rx['spec_rx_lintvprismbase']; ?></td>
      </tr>
      <tr>
        <td> </td>
        <td>User ID <?php echo $row_spec_rx['user_id']; ?></td>
        <td><?php echo $row_spec_rx['user_firstname']; ?></td>
        <td><?php echo $row_spec_rx['user_surname']; ?></td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
    </table>
    <p> </p>
    <?php } while ($row_spec_rx = mysql_fetch_assoc($spec_rx)); ?>
    <p> </p>
    <p> </p>
    <p> </p>
    </body>
    </html>
    <?php
    mysql_free_result($spec_rx);
    mysql_free_result($demographics);
    ?>

    Thanks for your help, nearly worked but only returned results where the if statement was met ie where locked =0, so I used an additional statement to display something else when when locked=1
    <?php
    if($row_spec_rx['locked'] == 1) {
    echo "button html goes here";
    ?>
    <?php
    if($row_spec_rx['locked'] == 0) {
    echo "something else";
    ?>
    I am sure there must be a more elegant way of doing this!

  • Help!!! : Complex mysql query in dreamweaver

    Ok Guys: I need this query executed on a client's website. I know it's working well in phpmyadmin, but in dreamweaver I cannot put it to work. The point is that the mysql_query funcion in PHP can only execute one query, So I cannot set the initial values of the parameters. I tried to translate it into dreamweaver standard code but the result gives onlyone record for each cat_news_id, while I need three. Any help please?
    ================mysql code================================
    SET @c :=0;
    SET @a :=0;
    SELECT n.id, n.cat_news_id, IF( @c = n.cat_news_id, @a := @a +1, @a :=1 ) AS rownum, (
    @c := n.cat_news_id
    ), n.foto, DATE_FORMAT( n.data, '%d/%m/%Y' ) AS data_it, n.ora, n.titolo, n.testobreve, n.pubblicata, n.primopiano, n.visite, nc.cat_news_name
    FROM tb_news n
    INNER JOIN tb_cat_news nc ON n.cat_news_id = nc.cat_news_id
    WHERE n.pubblicata =1
    GROUP BY n.cat_news_id, rownum
    HAVING rownum <=3
    ORDER BY n.id DESC
    ==============end mysql code==========================================
    ================dreamweaver code================================
    $intCounter_rsNotizie = "0";
    $intCategory_rsNotizie = "0";
    mysql_select_db($database_ConnInterista, $ConnInterista);
    $query_rsNotizie = sprintf("SELECT n.id, n.cat_news_id, IF( %s = n.cat_news_id, %s = %s +1, %s =1 ) AS rownum, ( %s =  n.cat_news_id ), n.foto, DATE_FORMAT( n.data, '%%d/%%m/%%Y' ) AS data_it, n.ora, n.titolo, n.testobreve, n.pubblicata, n.primopiano, n.visite, nc.cat_news_name FROM tb_news n INNER JOIN tb_cat_news nc ON n.cat_news_id = nc.cat_news_id WHERE n.pubblicata =1 GROUP BY n.cat_news_id, rownum HAVING rownum <=3 ORDER BY n.id DESC", GetSQLValueString($intCategory_rsNotizie, "int"),GetSQLValueString($intCounter_rsNotizie, "int"),GetSQLValueString($intCounter_rsNotizie, "int"),GetSQLValueString($intCounter_rsNotizie, "int"),GetSQLValueString($intCategory_rsNotizie, "int"));
    $rsNotizie = mysql_query($query_rsNotizie, $ConnInterista) or die(mysql_error());
    $row_rsNotizie = mysql_fetch_assoc($rsNotizie);
    $totalRows_rsNotizie = mysql_num_rows($rsNotizie);
    ==============end dreamweaver code==========================================
    Thanks for your interest

    Hi there Walt,
    Thanks for your reply....A stored procedure...yes. I should have thought about it. In this particular case I will try this way out since I have a root account and I can execute any mysql code. Usually, anyway, I found that web hosts tend to leave little grants to their clients mysql user accounts and even setting up a stored procedure could be an issue. I would be happy to find also a lighter solution, if possible....Anyway I will let you know if I could put the stored procedure solution to work.
    Thanks again for your hint!

  • DATE_FORMAT in filtered recordset

    I am having trouble formatting the date with php/MySQL in a filtered recordset. I am looking at the tutorial on http://forums.adobe.com/thread/450108 which shows how to do it. I've gotten it to work for a regular query but it sends back errors when I try to insert it into a filtered recordset. Here is the code I am trying but it's not working.
    $blog_id = "-1";
    if (isset($_GET['blog_id'])) {
      $blog_id = $_GET['blog_id'];
    $query_blog_comments = sprintf("SELECT blog_id, blog, comment, display, DATE_FORMAT(date, '%W, %M %e, %Y') AS date_formatted FROM blog_comment WHERE blog_id = %s AND display = 1 ORDER BY blog_id ASC", GetSQLValueString($blog_id, "text"));
    Please tell me how to format a date for a filtered recordset. Thanks!

    Heya,
    Try this code:
    $blog_id = "-1";
    if (isset($_GET['blog_id'])) {
      $blog_id = $_GET['blog_id'];
    $query_blog_comments = sprintf("SELECT
    blog_id, blog, comment, display,
    DATE_FORMAT(date, '%%W, %%M %%e, %%Y')
    AS date_formatted
    FROM blog_comment
    WHERE blog_id = %s
    AND display = 1
    ORDER BY blog_id ASC",
    GetSQLValueString($blog_id, "text"));
    The difference is an extra '%' placed in each date variable of DATE_FORMAT

  • Spry accordion with php mysql as data

    Hello
    I`m trying to create a spry accordion where the Labels are pulled from a mysql database table and the Content of that label is pulled from data in the same database. I tried adding first the spry accordion and then created 1 recordset for the labels and a second recordset for the content , then I added a repeat region for the labels DIV and inside this div I added a repeat region for the content.
    Unfortunatly when viewed in the browsers the accordion doesn`t work.
    Can anyone look at the code and tell me where is the mistake.
    Thanks
    <?php require_once('Connections/log.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    mysql_select_db($database_log, $log);
    $query_log_year = "SELECT DISTINCT Year(`23849`.acoff) AS yy FROM `23849` ORDER BY Year(`23849`.acoff)";
    $log_year = mysql_query($query_log_year, $log) or die(mysql_error());
    $row_log_year = mysql_fetch_assoc($log_year);
    $totalRows_log_year = mysql_num_rows($log_year);mysql_select_db($database_log, $log);
    $query_log_year = "SELECT DISTINCT Year(`23849`.acoff) AS yy FROM `23849` ORDER BY Year(`23849`.acoff)";
    $log_year = mysql_query($query_log_year, $log) or die(mysql_error());
    $row_log_year = mysql_fetch_assoc($log_year);
    $totalRows_log_year = mysql_num_rows($log_year);
    $mhour_log_mon = "0";
    if (isset($row_log_year['yy'])) {
      $mhour_log_mon = $row_log_year['yy'];
    mysql_select_db($database_log, $log);
    $query_log_mon = sprintf("SELECT DISTINCT DATE_FORMAT(`23849`.acoff, '%%M') AS mon , DATE_FORMAT(`23849`.acoff, '%%m') AS m , sum(`23849`.ablock) as toth FROM `23849` WHERE YEAR(`23849`.acoff) = %s GROUP BY m ORDER BY m ", GetSQLValueString($mhour_log_mon, "int"));
    $log_mon = mysql_query($query_log_mon, $log) or die(mysql_error());
    $row_log_mon = mysql_fetch_assoc($log_mon);
    $totalRows_log_mon = mysql_num_rows($log_mon);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>testing ajax php mysql</title>
    <script src="SpryAssets/SpryAccordion.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryAccordion.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="Accordion1" class="Accordion" tabindex="0">
      <div class="AccordionPanel">
        <?php do { ?>
          <div class="AccordionPanelTab"><?php echo $row_log_year['yy']; ?></div>
          <?php } while ($row_log_year = mysql_fetch_assoc($log_year)); ?>
    <div class="AccordionPanelContent">
      <table width="100%" border="0" cellspacing="5" cellpadding="5">
        <?php do { ?>
          <tr>
            <td><?php echo $row_log_mon['mon']; ?></td>
            <td><?php echo $row_log_mon['toth']; ?></td>
          </tr>
          <?php } while ($row_log_mon = mysql_fetch_assoc($log_mon)); ?>
      </table>
    </div>
      </div>
    </div>
    <script type="text/javascript">
    <!--
    var Accordion1 = new Spry.Widget.Accordion("Accordion1");
    //-->
    </script>
    </body>
    </html>
    <?php
    mysql_free_result($log_year);
    mysql_free_result($log_mon);
    ?>

    You only have 1 "AccordianPanel" which contains a list of "AccordianPanelTab" elements, then a list of "AccordianPanelContent" elements.
    You need to have a list of "AccordianPanel" elements, each containing a pair or "AccordianPanelTab" and "AccordianPanelContent" elements.
    HTH,
    Randy

  • Noob help to format date to insert into mysql

    Sorry, if this question has been asked before, I did di a search but could not find an answer that I could understand.  I am pretty new to DW and my coding skills are not good so please go easy on me.
    I have a simple form to insert records to a mysql database.  I have created a form validarion behaviour to require the fields that are set as not-NULL in the database.  How do I modify the code to allow the date format to be entered in the dob field in the form as DD/MM/YYYY but inserted correctly in the database as YYYY/MM/DD?
    Finally, how would I then modify it further to default to todays date?
    Here's my code:
    <?php require_once('Connections/mypms.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO demographics (title, firstname, surname, dob, address1, address2, town, county, postcode) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['firstname'], "text"),
                           GetSQLValueString($_POST['surname'], "text"),
                           GetSQLValueString($_POST['dob'], "date"),
                           GetSQLValueString($_POST['address1'], "text"),
                           GetSQLValueString($_POST['address2'], "text"),
                           GetSQLValueString($_POST['town'], "text"),
                           GetSQLValueString($_POST['county'], "text"),
                           GetSQLValueString($_POST['postcode'], "text"));
      mysql_select_db($database_mypms, $mypms);
      $Result1 = mysql_query($insertSQL, $mypms) or die(mysql_error());
    $recordID = mysql_insert_id();
      $insertGoTo = "detail_tab.php?recordID=$recordID";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
      exit();
    $colname_insert = "1";
    if (isset($_GET['recordID'])) {
      $colname_insert = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
    mysql_select_db($database_mypms, $mypms);
    $query_insert = sprintf("SELECT px_id, title, firstname, surname, dob, address1, address2, town, county, postcode FROM demographics WHERE px_id = %s", $colname_insert);
    $insert = mysql_query($query_insert, $mypms) or die(mysql_error());
    $row_insert = mysql_fetch_assoc($insert);
    $totalRows_insert = mysql_num_rows($insert);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>address</title>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    function MM_validateForm() { //v4.0
      var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
      for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
        if (val) { nm=val.name; if ((val=val.value)!="") {
          if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
            if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
          } else if (test!='R') { num = parseFloat(val);
            if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
            if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
              min=test.substring(8,p); max=test.substring(p+1);
              if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
        } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
      } if (errors) alert('The following error(s) occurred:\n'+errors);
      document.MM_returnValue = (errors == '');
    //-->
    </script>
    </head>
    <body>
    <p> </p>
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" onSubmit="MM_validateForm('firstname','','R','surname','','R','dob','','R');return document.MM_returnValue">
      <table align="center">
        <tr valign="baseline">
          <td nowrap align="right">Title:</td>
          <td><input type="text" name="title" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Firstname:</td>
          <td><input type="text" name="firstname" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Surname:</td>
          <td><input type="text" name="surname" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Dob:</td>
          <td><input type="text" name="dob" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Address1:</td>
          <td><input type="text" name="address1" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Address2:</td>
          <td><input type="text" name="address2" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Town:</td>
          <td><input type="text" name="town" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">County:</td>
          <td><input type="text" name="county" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Postcode:</td>
          <td><input type="text" name="postcode" value="" size="32"></td>
          <td><input name="Search" type="button" id="Search" value="Search"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right"> </td>
          <td><input type="submit" value="Insert record"></td>
          <td> </td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1">
    </form>
    <p> </p>
    </body>
    </html>
    <?php
    mysql_free_result($insert);
    ?>
    Thank you for your help :-)

    barrydocks wrote:
    thanks for the reply osgood;
    I was hoping for a more simple solution than a JQuery date picker, I have read this threat where the SQL queries is aletered:
    http://forums.adobe.com/thread/450108
    Which I tried but could not make work.
    I haven't tried DATE_FORMAT but the example implies that it would work when SELECTING the date from the database to output to a page in a more conventional FORMAT. However you want to INSERT the date using the correct format.
    barrydocks wrote:
    http://forums.adobe.com/thread/1097555
    but I don't know how to use this in my code that already has form validation?
    That thread is implying that you would need to convert the date inserted into the form field before it is inserted into the database in the correct format.......so you may as well use a datepicker.
    Problem with letting anyone insert a date manually is that a date can be written in many formats which are NOT acceptable by the database. A datepicker overcomes all of these issues. Getting the date back out of the database is a case of simply converting via php into a format which is applicable to your country or your usage OR using the method in the first thread you provided.
    Lets see if anyone else can offer a more simple solution for you.

  • PHP/MySQL Date Format problems

    Dear all,
    In the past I successfully formatted a date from a Unix date format to my own desired output by using a PHP command as such:
    echo date($row_rsGNresults['date'], "Y F j"); 
    For a reason unbeknown to me, this no longer works and no matter what I try, the page always returns the date results in yyyy-mm-dd format.
    I've even tried using date format in the SQL query:
    SELECT * DATE_FORMAT('date', '%Y %F %j') AS showdate FROM gemnews_tab WHERE language LIKE %s AND entry LIKE %s AND works LIKE %s AND category LIKE %s ORDER BY date ASC 
    I've even tried installing various Dreamweaver extensions for date server formats (like Kaosweaver's) to no avail.  I've checked MySQL and the field is definitely set to 'date' and the dates are in yyyy-mm-dd format.
    Does anyone have any suggestions?  Would it matter that the dates are from the 18th century?
    Many Thanks
    J
    Message was edited by: Günter Schenk. Reason: the "PHP command" code was invisible

    Try this:
    <?php echo Date("M d, Y",
    strtotime($row_Recordset1['review_date'])); ?>
    Ken Ford
    Adobe Community Expert
    Fordwebs, LLC
    http://www.fordwebs.com
    "newhorizonhosting.com" <[email protected]>
    wrote in message news:et7lf6$q8a$[email protected]..
    > Can someone help me out here. I am trying to format my
    date. My MySQL is a
    > "datetime". How ever I would like to display only the
    month, day, year like so
    > "Jan,15,2007"
    >
    > Here is my current code, what should I add to make it do
    what I want.
    >
    > <?php echo $row_Recordset1['review_date']; ?>
    >
    > Thanks
    >

  • Date_format and order by date problem

    Hi,
    I have a problem with taking the resultset as sorted by date.
    example1:
    SELECT
    T.foreign_network_id as "Network ID",
                             date_format(T.ARRIVAL_DATE,'%d-%m-%Y') as "Date",
                        sum(case when((networks_rejected = 0)
                                       and (T.sor_reapply = 'N')
                                       and (T.sor_reason in ('NP', 'NU', 'NT', 'HT')))
                                       then T.CNT else 0 end) as "Before Steering",
                   sum(case when(sor_reason in ('NP', 'HT', 'T2', 'TM', 'NM', 'MM', 'IPMM', 'NPMM'))
                                  then T.CNT else 0 end) as "After Steering"
              FROM     ST_INC T,
                        NETWORKS N,
                        ZONE_NW_MAP ZN,
                        ZONES Z,
                        PAYMENT_TYPE PT
              WHERE      T.FOREIGN_NETWORK_ID = N.NETWORK_ID
              AND      ZN.NETWORK_ID = N.NETWORK_ID
              AND      Z.ZONE_ID = ZN.ZONE_ID
              AND      PT.id = T.ptype
              AND opcode = 2
              AND      sor_action is not null
                             and Z.ZONE_ID = 269
                   group by
                             date_format(T.ARRIVAL_DATE,'%d-%m-%Y'),
    T.foreign_network_id
    order by      date_format(T.ARRIVAL_DATE,'%d-%m-%Y')
    There is no problem with example 1 however it sorts the result set as if the date field is a string. I know this should be because I use date_format with order by. When I delete and only use T.ARRIVAL_DATE, I get "not a group by expression" error. And the reason why I use date_format is that sometimes I want to retrieve different format such as '%m-%Y' or only '%Y'. So I am required to use date_format, but then I lose the chance to sort by the actual date. I tried to select "T.ARRIVAL_DATE" as another extra colum and sort with respect to that. But this time I lost tha chance to select it again in the date_format function. Can anybody help me, I am messed up here?
    Edited by: user13378594 on Aug 26, 2010 3:00 PM

    user11268895 wrote:
    ... you are in an PL/SQL forum not in a mysql forum.
    if you want we can translate your query in a Oracle DB query...Well... MySql is an Oracle Database...
    to the op:
    If you want to order then you need an ORDER BY clause at the end of your statement.
    Instead of date_format you can use TO_DATE if dealing if strings. If it is a datatype date, then there is no need of a conversion.
    group by T.ARRIVAL_DATE, T.foreign_network_id
    order by t.arrival_date descyou could also group on the day or the month if that is what you want.
    day groups
    select trunc(T.ARRIVAL_DATE), ...
    group by trunc(T.ARRIVAL_DATE), T.foreign_network_id
    order by trunc(T.ARRIVAL_DATE) desc;
    month groups
    select trunc(T.ARRIVAL_DATE,'mm'), ...
    group by trunc(T.ARRIVAL_DATE,'mm'), T.foreign_network_id
    order by trunc(T.ARRIVAL_DATE,'mm') desc;
    boy groups
    select trunc(T.ARRIVAL_DATE,'boy'), ...
    group by trunc(T.ARRIVAL_DATE,'boy'), T.foreign_network_id
    order by trunc(T.ARRIVAL_DATE,'boy') desc;
    /* Ok, ignore the last one, I was just testing if you read until the end. */ Edited by: Sven W. on Aug 26, 2010 2:25 PM

  • Date Manipulation in PHP, MySQL, ADDT

    I have a datetime stored in MySQL  I retrieve it from the ADDT update transaction via the following statement:
    $last_date = KT_escapeForSql($tNG->getColumnValue("last_kpi_gen_date"),$tNG->getColumnType("last_kpi_g en_date"));
    Now I want to add 1 day, 7 days, or a month to the date.  I try using mktime but it appears it wants it in a different date order (h,m,s, y-m-d),  I've tried the strtotime function and the date function to reformat $last_date, but it doesn't seem to work.
    Is there an easy way to add days to a date varible extracted from a MySQL database using ADDT getColumnValue?

    Hi, I am trying to do it this way:
    You can make VIEW for MySQL with current time +8 hours:
    create view DATETIME as
    SELECT DATE_FORMAT(DATE_ADD(now(), INTERVAL 8 HOUR), '%Y-%m-%d %H:%i:%s') as DT_add8hour;
    Or with +8 days:
    create view DATETIME as
    SELECT DATE_FORMAT(DATE_ADD(now(), INTERVAL 8 DAY), '%Y-%m-%d %H:%i:%s') as DT_add8day;
    This stores allways CURRENT time plus interval value. So You can use this to update other table colums to time you want. Works perfectly with DW+ADDT+PHP+MySQL  
    Here are more Date and Time Functions
    Hope this helps you!
    Message was edited by: asdaf1234

  • Making MySQL ORDER BY link dynamic in URL

    I would like to have a dynamic table sorted by a dynamic URL.
    I have found this script but I am not sure where I am meant
    to put the DECLARE?
    This is the MySql recordset:
    BEGIN
    DECLARE @SortOrder tinyint
    SET @SortOrder = 2
    SELECT *
    FROM products
    WHERE `Section` = colname OR `Department` = colname2
    ORDER BY CASE WHEN @SortOrder = 1 THEN Code
    WHEN @SortOrder = 2 THEN Name
    ELSE Order
    END
    I get an error saying this:
    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 'DECLARE @SortOrder tinyint SET @SortOrder = 2 SELECT *
    FROM products WHERE `Sec' at line 2
    Any ideas? And in the script what does the number 2 in this [
    SET @SortOrder = 2 ] refer to? Two CASES?

    I don't know for sure, but one thing I see is that you are using an alias which has the same name as the column:
    DATE_FORMAT(date_created, '%m/%d/%Y %l:%i %p') AS 'date_created',
    Then the order by clause is using that same column/alias. Maybe this is confusing MySQL?  If MySQL supports alias's based on functions in the order by clause, you might want to change that alias name to something else, like date_created_alias and use that in the order by.
    Otherwise, try using the complete function in the order by clause:
    ORDER BY DATE_FORMAT(date_created, '%m/%d/%Y %l:%i %p')  DESC
    But in any case, it sure seems like it should be sorting correctly the way you are currently handling it.

  • Java MySQL  ResultSet Help

    How do I read the result of query -
    "SELECT unix_timestamp(date_format(now(), '%Y-%m-%d %H') )"
    from Java Result Set to a String variable in Mysql..
    I tried -
    Connection conn = getConnection( );
    Statement s = connection.createStatement();
    ResultSet rs = s.executeQuery( "SELECT unix_timestamp(date_format(now(), '%Y-%m-%d %H') )" );
    String result = resultSet.getString( "unix_timestamp(date_format(now(), '%Y-%m-%d %H') )");
    I don't get the value in result..rather I get the exception...My resultSet comes as not null from database.
    Thanks!

    You are using one variable when executing query and using another variable when accessing data. See the bolded values.
    Connection conn = getConnection( );
    Statement s = connection.createStatement();
    ResultSet rs = s.executeQuery( "SELECT unix_timestamp(date_format(now(), '%Y-%m-%d %H') )" );
    String result = resultSet.getString( "unix_timestamp(date_format(now(), '%Y-%m-%d %H') )");

Maybe you are looking for

  • Why it is not possible to install apps on an SD card on a Win 8.1 tablet?

    Why it is not possible to install apps on an SD card on a Win 8.1 tablet? If it is possible to install apps on SD card in Windows phone 8.1, why is it not possible on Windows 8.1? What sort of design philosophy you follow that gives better features o

  • How do you close a dragged applet, as Stage.close() doesn't work?

    I'm trying to implement a close button in a draggable applet, but Stage.close() doesn't work, and there's an odd little "X" icon which is causing me problems... My starting point and example is the simple draggable applet from the API documentation.

  • Using Stored Procedure in JSP

    Hi Everybody, I hope some one can help me out. I want to call a PL/SQL Procedure in my JSP Page. Can anybody please tell me how this can be done. Thanks

  • IPod Photo 60GB + iTunes 7.0.2 = Misery

    Well, what a miserable day here. I have three iPods, a nano, a 4th Gen 60 GB Photo, and a 1st Gen Shuffle. None of them will synch properly with the Intel iMac. I have the symptoms reported by others - inside iTunes, the iPods cannot be updated or re

  • How to transport the festive calendar?

    Hi experts! I need to transport the festive calendar to a customizing order, If I do this in IMG, I don't have the transport order and I received a message saying I have to do this manually... does anybody know how can I do this? thanks a lot Regards