Thursday, August 29, 2013

How to make Time ?

Hi,

Sorry If you have been misguided into this blog, well its technical and nothing Out of the world

I found this site very useful,
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

The site has all the Time/Date related API's, There are a lots of FUN things available there
like

a)How to make time ?

SELECT MAKETIME(9,45,45);

SELECT MAKETIME(9,45,61); --------------WILL GIVE YOU NULL VALUE !!!

b)How to make date ?


How to get Present Time difference between two times / two dates in mysql

SELECT NOW(), SLEEP(3), SYSDATE();


I found this site very useful,
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

The site has all the Time/Date related API's, There are a lots of FUN things available there
like

a)How to make time ?
b)How to make date ?
and etc.............




How to get the difference between two dates / time in mysql

CREATE TABLE users (
  users_name varchar(20) NOT NULL,
  users_starttime datetime DEFAULT '00-00-0000 00:00:00' NOT NULL,
  users_endtime datetime DEFAULT '00-00-0000 00:00:00' NOT NULL
);

insert into users (users_name, users_starttime) values('Balaji', NOW());

update users set users_endtime = NOW();

select * from users;

SELECT TIMEDIFF(users_endtime,users_starttime) FROM users;
SELECT TIMESTAMPDIFF(SECOND,users_starttime,users_endtime) FROM users;