Apply for Zend Framework Certification Training

Mysql






HI viewers ,
  Lets Do some Time stamp related operations
  we have to calculate date difference for login attempts .
  So we will start with Now() which results corrent timestamp.
TIMESTAMPDIFF()
  can be used to return a date difference as an integer.
  This can be used to calculate differences in year, quarter, month, week,
  day, hour, minute, second, and microsecond.
6# In this statement SUBDATE is used to deduct 2 HOUR from current operation

 

SELECT NOW();

SELECT * FROM account_department;

SELECT TIMEDIFF(Login, Logout) AS Difference
  from account_department;

SELECT created_on , NOW(),
   IF(TIMESTAMPDIFF(MINUTE,created_on,NOW()) >120,
    'more then 2 hour','less then two hour') AS difference 
FROM account_department;

SELECT created_on , NOW(),
	IF(TIMESTAMPDIFF(MINUTE,created_on,NOW()) >120,
        'more then 2 hour','less then two hour') AS difference 
FROM  account_department WHERE STATUS = 0;

6#  SELECT * FROM account_department WHERE created_on
  < SUBDATE( CURRENT_TIMESTAMP, INTERVAL 2 HOUR)
   AND STATUS = 0;                          

< what is the difference between myisam and innodb How to get last record from table >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top