473,394 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

PHP5.2.5 not displaying the correct output from MSSQL query

10
In MSSQL I am using datetime as the column type and trying to execute the below mentioned query

select time from tickets where ticket_id = '1';

when i execute the query on sql manager window it shows it correctly with seconds and milliseconds in the output like this

2008-01-30 13:58:04.000

But when i run the sql through PHP 5.2.5 it replaces the seconds and milliseconds with AM/PM
sql1="select time from tickets where ticket_id = '1' ";
$row1=mssql_query($sql1);
$res1=mssql_fetch_assoc($row1);
print_r($res1);
output comes like this

Array ( [time] => Jan 30 2008 1:52PM )

Please help on how to get the full datetime including seconds and milliseconds and not with AM/PM using PHP 5.2.5

Thanks
Jan 30 '08 #1
2 2356
Expand|Select|Wrap|Line Numbers
  1. sql1="select `time` from tickets where ticket_id = '1' ";
  2.  
Use backticks for "strange" column names which are also mysql functions.
Hope this helps.
Jul 17 '08 #2
code green
1,726 Expert 1GB
MsSql doesn't like backticks.

This is a quirk of php-mssql.
I have never needed the precision of seconds so has never worried me,
but this topic has been raised on the sql server forum.
Not sure if an explanation was found.
However you could use CONVERT
Expand|Select|Wrap|Line Numbers
  1. SELECT CONVERT(VARCHAR, time,113) FROM tickets where ticket_id = '1' 
I think is right. There are varitions if you Google and 113 is one of many format codes.
But be aware the data type HAS been converted to a non datetime format.
So if you want to do datetime comparisons you will need to use strtotime
[PHP]$time = strtotime($result['time'][/PHP]
Jul 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: billy.becker | last post by:
I need to save a wav file that is HTTP POSTed to a php page. What does PHP5 do automatically to a POSTed variable when it puts it in the $_POST superglobal array? I haven't been able to find any...
11
by: ralphie | last post by:
hi all since nearly 2 days i fight with mssql and utf-8 as i need to store and retrieve arabic characters. i tried the com approach ...
2
by: niraj.sanghvi | last post by:
I just upgraded to PHP5 from PHP4, and most of the transition was seamless. But my forms don't appear to be working correctly now. Where I have the following: if($runquery) { Use $POST values......
2
by: Stefan Huber | last post by:
Hi I've got a really strange problem, and can't find out why it's not working as intended. in order to use php4 and 5 together on a webserver and the requirement for running as different...
1
by: wallacee | last post by:
Five year PL/SQL programmer with a MSSQL question. I need to spool (the PL/SQL verb) output to a file from an MSSQL statement. In PL/SQL it would look like: spool myoutput.txt select...
2
by: Alfred | last post by:
I'm about to host a solution for our developers and it will use PHP5 on Suse Enterprise Linux 9 and MS SQL Server API. The developers are kind of green to this. Is this MS SQL Server API fairly...
8
by: FFMG | last post by:
Hi, I am slowly moving my code to php5. But I would like to make it backward compatible in case something bad happens, (and to make sure I understand what the changes are). The way the...
1
by: David Gillen | last post by:
Hello. I'm having difficulty getting the value of output parameters from stored procedures on a SQL server. I understand that this just doesn't work with odbc so I've tried both the mssql...
7
by: Chuck Anderson | last post by:
I can tell I'm not alone in my confusion, as I've been using Google to find a solution to this problem and all I can find is the same question, but no solution. I am running Php 5.25 (Windows...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.