#1
  1. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    UK
    Posts
    17
    Rep Power
    0

    Question CONVERT Date? How to display results?


    Hi there,
    I am trying to pull out the birthday dates from a table (MS SQL SERVER) so that the table that is displayed on the website only displays a list of birthdays.
    My table contains the DOB column in datetime format.
    I have used the following query in SQL Server Enterprise Manager:

    SELECT CONVERT(varchar(10),DOB,103) FROM table1

    and it works fine. It returns the date the way I want it - in SQL Server Enterprise Manager.

    However, when I try to display it on the website, I am getting ZERO results. Nothing is displayed.
    This is my code on the PHP site:

    $query = "SELECT CONVERT(varchar(10),DOB,103) FROM table1";

    $result=@mssql_query ($query);

    while ($Row=@mssql_fetch_array($result))
    {

    echo("<tr><td><b>$Row[DOB]</b></td></tr>\n");

    }

    How would I get the results from the query displayed in my table?

    Or do I retrieve all DOBs first and then convert them once they are retrieved?
    No clue....

    Thanks for your help,
    N
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,205
    Rep Power
    4279
    your query is fine

    your problem seems to be php

    you stand a better chance of getting an answer in the php forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    UK
    Posts
    17
    Rep Power
    0
    cheers. will try that. thought it was a SQL thingy.

    N

IMN logo majestic logo threadwatch logo seochat tools logo