Hello!

How can i extract only the date part from a datetime field in MSSQL?

I have a field declared "test datetime NULL" in a table named "table1".

The guerry is: "select datetime from tabe1"... pass this with php and the output on the browser is ... somthing like that:
"Jan 16 2003 12:00AM" .... only that i want to have "Jan 16 2003" on my browser!!!
It's posible to extract only the date part from the datetime field with a MSSQL command?
PS: I don't want to use php function to extract what I need for! (already use this method )! HAVE A NICE DAY!

    Hi there -

    You can format it as you pull it from the database:

    "SELECT date_format(datetime, '%M %e, %Y') AS date FROM...." //where 'datetime' is your datetime column in the database

    will format it like this:

    "November 12, 2003"

    Jamie

      Write a Reply...