Get the Difference Between Two Timestamps in Seconds in MySQL

Rishi Rathor
Updated on 30-Jul-2019 22:30:24

1K+ Views

To get difference between two timestamps in seconds, use two in-built functions TIME_TO_SEC() and TIMEDIFF() in MySQL. The syntax is as follows −select time_to_sec(timediff(yourCoulnName1, yourCoulnName2)) as anyVariableName from yourTableName;To understand the above concept, let us first create a table. The query to create a table.mysql> create table TimeToSecond −> ( −> MyTime timestamp, −> YourTime timestamp −> ); Query OK, 0 rows affected (0.48 sec)Now you can insert some datetime values in the table. The query is as follows −mysql> insert into TimeToSecond values('2016-05-10 10:02:00', '2016-05-10 10:00:00'); Query ... Read More

Codes of Engineering Ethics

Knowledge base
Updated on 30-Jul-2019 22:30:24

5K+ Views

The engineering societies such as AAES, ABET, NSPE, IEEE, and AICTE have framed these codes of ethics which are helpful to engineers to strengthen the moral issues on their work. The codes of ethics play at least eight important roles such as the following.Serving and Protecting the PublicEngineers are in a responsible position where trust and trustworthiness, both are essential. A code of ethics functions as a commitment to the profession as a whole that engineers will serve the public health, safety, and welfare. All the remaining ones contribute to this function in some or other way.GuidanceCodes are written in ... Read More

Go-Back-N ARQ Protocol

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

13K+ Views

Go-Back-N Automatic Repeat reQuest (Go-Back-N ARQ), is a data link layer protocol that uses a sliding window method for reliable and sequential delivery of data frames. It is a case of sliding window protocol having to send window size of N and receiving window size of 1.Working PrincipleGo – Back – N ARQ uses the concept of protocol pipelining, i.e. sending multiple frames before receiving the acknowledgment for the first frame. The frames are sequentially numbered and a finite number of frames. The maximum number of frames that can be sent depends upon the size of the sending window. If ... Read More

Modify Value in Java HashMap

Samual Sam
Updated on 30-Jul-2019 22:30:24

350 Views

First, create a HashMap and add elements to it −// Create a hash map HashMap hm = new HashMap(); // Put elements to the map hm.put("Bag", new Integer(1100)); hm.put("Sunglasses", new Integer(2000)); hm.put("Frames", new Integer(800)); hm.put("Wallet", new Integer(700)); hm.put("Belt", new Integer(600));Now, to modify the value associated with a given key, use the put() method. Here, we are modifying the value for the key “Frames” −hm.put("Frames", "900");The following is an example to modify the value associated with a given key −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { ... Read More

Create a TreeMap in Java and Add Key-Value Pairs

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

1K+ Views

A TreeMap cannot contain duplicate keys. TreeMap cannot contain the null key. However, It can have null values.Let us first see how to create a TreeMap −TreeMap m = new TreeMap();Add some elements in the form of key-value pairs −m.put(1, "India"); m.put(2, "US"); m.put(3, "Australia"); m.put(4, "Netherlands"); m.put(5, "Canada");The following is an example to create a TreeMap and add key-value pairs −Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       TreeMap m = new TreeMap();       m.put(1, "India");       m.put(2, "US");       m.put(3, "Australia");     ... Read More

Purpose of Any Research

Ridhi Arora
Updated on 30-Jul-2019 22:30:24

496 Views

When a new product developed, the Research and Development department initiate and perform an intensive study and get the details to support the project. Research and Development departments help corporations stay ahead of the competition, utilize new technology, and produce goods more efficiently. This is just the purpose of any research.Research PhaseThe research phase includes determining product specifications, production costs, and a production timeline.It contributes to the development, as a scientist or inventor in the field of Science and Technology. The research plan is a map for one’s career as a research science professional.In the medical field, research enables us ... Read More

Display File Class Constants in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

160 Views

The java.io.File class has display constants File.separatorChar and File.pathSeparatorChar mainly. The File.separatorChar is ‘/’ and the File.pathSeparatorChar is ‘:’ for Unix.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) {       try {          System.out.println("File.pathSeparatorChar = " + File.pathSeparatorChar);          System.out.println("File.separatorChar = " + File.separatorChar);       } catch(Exception e) {          e.printStackTrace();       }    } }The output of the above program is as follows −OutputFile.pathSeparatorChar = : File.separatorChar = /Now let ... Read More

Count All Rows Per Table in One Query in MySQL

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

293 Views

You can count all rows per table with the help of aggregate function count (TABLE_ROWS) from informatio_schema.tables. The syntax is as follows −SELECT table_name, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'yourDatabaseName';Now you can apply the above syntax to get all rows per table. The query is as follows −mysql> SELECT table_name, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'business';Here is the output −+------------------------------------------------------------------+------------+ | TABLE_NAME                                                       | TABLE_ROWS | +------------------------------------------------------------------+------------+ | accentsearchdemo       ... Read More

Compare Date String with MySQL Datetime Field

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:24

1K+ Views

You can compare DATE string with string from DATETIME field with the help of DATE() function in MySQL.The syntax is as follows −select *from yourTableName where DATE(yourColumnName) = ’anyDateString’;To understand the above syntax, let us create a table and set some datetime values in the table. The query to create a table −mysql> create table DateTimeDemo −> ( −> ArrivalTime datetime −> ); Query OK, 0 rows affected (0.61 sec)Let us insert some records in the table with the help of insert command. The following is the query to insert records ... Read More

Smooth Image Rotation in Android

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

1K+ Views

This example demonstrates how to make a smooth image rotation in Android.Step 1 - Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 - Add the following code to res/layout/activity_main.xml.         In the above code, we have taken a text view and image view. When you click on text view, Image will get rotate in anti clock direction.Step 3 - Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.view.animation.Animation; import android.view.animation.LinearInterpolator; ... Read More

Advertisements