473,386 Members | 1,710 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,386 software developers and data experts.

How to perform this data type conversion and following it up with SUM operation?.

I get data from a MS SQL table. The data has a data type of nchar. A sample data is as follows,

00:00:01.5000000

The above data represents Hrs:Mins:Secs

Now i need to convert this data into a suitable data type so that i can add all such related data. After adding i will get total hrs, mins and secs. How can i do this. Please provide some ideas.
May 12 '08 #1
2 1016
TheServant
1,168 Expert 1GB
You will need to separate that data (reg expressions) into the different components (day, month, year, hour, minute and seconds) and then use a function like mktime() to convert it to a time stamp. Once it is in that form you can add or subtract. Once you have done what you wanted, you can convert it back to date format using the date() function.

Hope that helps.
May 13 '08 #2
Atli
5,058 Expert 4TB
Hi.

Once your data is available to your PHP code, the simplest way to parse this into something useful would be to use the explode function to split it up into hours, minutes and seconds, and then use it again to split the seconds and milliseconds.

Although, it would probably be cleaner to use a regular expression via the preg_match function.
May 13 '08 #3

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

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
3
by: Thomas Coleman | last post by:
I have been playing around with 2.0 and I'm trying clarify a few things about generics and data access. I was hoping to be able to do something like this with nullable types: int? foo = null; ...
1
by: gary.scott | last post by:
Aaaaaarrgghh ! (that's better) I am trying to convert a field within my Oracle 9i Database that is of type BLOB (but this BLOB may contain a combination of clobs/varchars or images such as gif...
9
by: Ralf Hildebrandt | last post by:
Hi all! First of all: I am a C-newbie. I have noticed a "strange" behavior with the standart integer multiplication. The code is: void main(void)
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.