Overthere
asked on
PHP5 and extracting MS SQL Server DateTimeStamp from table
Hello folks,
I have a MS Sql Server table. One of the columns is a DateTime stamp.
I need only to extract the date. When I use the code:
gives me can "not convert to string" which I understand.
I need to only pull the date and not time, I know I can reformat the date once I successfully
assign it to a variable but that's the problem -
How do I assign it to a variable? Can I reformat the date before assigning it to the variable?
I see all sorts of info about date/time in the php manual but they are using constants, not something pulled
from a table...
I have a MS Sql Server table. One of the columns is a DateTime stamp.
I need only to extract the date. When I use the code:
$hiredate = $row["HireDate"];
gives me can "not convert to string" which I understand.
I need to only pull the date and not time, I know I can reformat the date once I successfully
assign it to a variable but that's the problem -
How do I assign it to a variable? Can I reformat the date before assigning it to the variable?
I see all sorts of info about date/time in the php manual but they are using constants, not something pulled
from a table...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't understand because almost everything that comes back from a database is in text format unless it is in one of the binary data types. Can you show us the CREATE TABLE or structure definition?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You have a point Mufur - converting within a sql query is very possible and I think more feasible.
I can also convert it to a date in php for date comparisons.
Thank you everyone for responding, its as always appreciated...
I can also convert it to a date in php for date comparisons.
Thank you everyone for responding, its as always appreciated...
ASKER
Just thought I would share this snippet.
This is the sql query that worked very well for me....
This is the sql query that worked very well for me....
SELECT LEFT(CONVERT(VARCHAR, HireDate, 120), 10)as HireDate, Paid FROM MyTable WHERE RecId = 1001
The SQL Query that worked so well for is not shown in your Accepted Solution while a similar solution is shown in my post above.