Get Only the Date in Timestamp in MySQL

Arjun Thakur
Updated on 25-Jun-2020 11:00:02

2K+ Views

In order to get the date from the timestamp, you can use DATE() function from MySQL.The syntax is as follows −SyntaxSELECT DATE(yourTimestampColumnName) as anyVariableName from yourTableName;To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table DateFromTimestamp -> ( -> ShippingDateTime timestamp -> ); Query OK, 0 rows affected (0.60 sec)Insert date and time for the column ShippingDateTime we created above.The query to insert record is as follows −mysql> insert into DateFromTimestamp values('2012-12-26 13:24:35'); Query OK, 1 row affected (0.14 sec) mysql> insert into DateFromTimestamp values('2013-11-26 14:36:40'); ... Read More

Shift Left in a BigInteger in Java

Samual Sam
Updated on 25-Jun-2020 10:59:45

205 Views

To shift left in a BigInteger, use the shiftLeft() method.The java.math.BigInteger.shiftLeft(int n) returns a BigInteger whose value is (this

Add a Temporary Column with a Value in MySQL

Rishi Rathor
Updated on 25-Jun-2020 10:48:13

4K+ Views

You can add a temporary column with value with the help of the following syntax −select yourColumnName1, yourColumnName2, .....N ,yourTemporaryColumnValue as yourTemporaryColumnName from yourTableName;To add a temporary column with a value, let us create a table. The following is the query −mysql> create table TemporaryColumnWithValueDemo    −> (       −> StudentId int,       −> StudentName varchar(100)    −> ); Query OK, 0 rows affected (0.59 sec)Inserting some records in the table. The query to insert records are as follows −mysql> insert into TemporaryColumnWithValueDemo values(101, 'John'); Query OK, 1 row affected (0.13 sec) mysql> insert into ... Read More

Calculate Average of Numbers in a Column using MySQL Query

Jennifer Nicholas
Updated on 25-Jun-2020 10:45:08

1K+ Views

Calculate the average of numbers in a column with the help of MySQL aggregate function AVG().The syntax is as follows −select avg(yourColumnName) as anyVariableName from yourTableName;To understand the above concept, let us create a table. The following is the query to create a table.mysql> create table AverageCalculateDemo    −> (       −> SubjectMarks int    −> ); Query OK, 0 rows affected (0.67 sec)The following is the query to insert some records into the table −mysql> insert into AverageCalculateDemo values(70); Query OK, 1 row affected (0.14 sec) mysql> insert into AverageCalculateDemo values(80); Query OK, 1 row affected ... Read More

Create a Queue Using LinkedList Class in Java

Samual Sam
Updated on 25-Jun-2020 10:40:41

283 Views

To create a queue using LinkedList class, try the following −Queue q = new LinkedList(); q.offer("abc"); q.offer("def"); q.offer("ghi"); q.offer("jkl"); q.offer("mno"); q.offer("pqr"); q.offer("stu"); q.offer("vwx");After that to print the elements, you need to use check a condition for Queue as shown below −Object ob; while ((ob = q.poll()) != null) {    System.out.println(ob); }The following is an example −Example Live Demoimport java.util.LinkedList; import java.util.Queue; public class Demo {    public static void main(String[] args) {       Queue q = new LinkedList();       q.offer("abc");       q.offer("def");       q.offer("ghi");       q.offer("jkl");       q.offer("mno"); ... Read More

Convert LinkedList to ArrayList in Java

karthikeya Boyini
Updated on 25-Jun-2020 10:39:09

7K+ Views

A LinkedList can be converted into an ArrayList by creating an ArrayList such that the parameterized constructor of the ArrayList initialises it with the elements of the LinkedList.A program that demonstrates this is given as follows −Example Live Demoimport java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class Demo {    public static void main(String[] args) {       LinkedList l = new LinkedList();       l.add("Orange");       l.add("Apple");       l.add("Peach");       l.add("Guava");       l.add("Pear");       List aList = new ArrayList(l);       System.out.println("The ArrayList elements are: ");     ... Read More

Replace Element of a Java LinkedList

Samual Sam
Updated on 25-Jun-2020 10:37:47

2K+ Views

An element in an Java LinkedList can be replaced using the java.util.ArrayList.set() method. This method has two parameters i.e the index at which the LinkedList element is to be replaced and the element that it should be replaced with. ArrayList.set() method returns the element that was at the position specified at the index previously.A program that demonstrates this is given as follows −Example Live Demoimport java.util.LinkedList; public class Demo {    public static void main(String[] args) {       LinkedList l = new LinkedList();       l.add("Pear");       l.add("Apple");       l.add("Mango");       l.add("Guava"); ... Read More

Usage of Element Method of Queues in Java

karthikeya Boyini
Updated on 25-Jun-2020 10:37:14

763 Views

The element() method in Java Queues is used to return the element at the front of the container and does not remove it.The following is an example. Firstly, create a Queue and add some elements −Queue q = new LinkedList(); q.offer("abc"); q.offer("def"); q.offer("ghi"); q.offer("jkl"); q.offer("mno"); q.offer("pqr"); q.offer("stu"); q.offer("vwx");Now use the element() method as shown below −System.out.println("Queue head = " + q.element());The following is the complete example −Example Live Demoimport java.util.LinkedList; import java.util.Queue; public class Demo {    public static void main(String[] args) {       Queue q = new LinkedList();       q.offer("abc");       q.offer("def");     ... Read More

CSS nav left Property

George John
Updated on 25-Jun-2020 10:36:49

188 Views

The nav-left property is used to move left when you have pressed on left arrow button in keypad. You can try to run the following code to implement the CSS nav-left propertyExampleLive Demo                    button {             position: absolute;          }          button#btn1 {             top: 10%;             left: 15%;             nav-index: 1;             nav-right: #btn2;             nav-left: #btn4;             nav-down: #btn2;             nav-up: #btn4;          }          button#btn2 {             top: 30%;             left: 30%;             nav-index: 2;             nav-right: #btn3;             nav-left: #btn1;             nav-down: #btn3;             nav-up: #btn1;          }          button#btn3 {             top: 50%;             left: 15%;             nav-index: 3;             nav-right: #btn4;             nav-left: #btn2;             nav-down: #btn4;             nav-up: #btn2;          }          button#btn4 {             top: 30%;             left: 0%;             nav-index: 4;             nav-right: #btn1;             nav-left: #btn3;             nav-down: #btn1;             nav-up: #btn3;          }                     Result1       Result2       Result3       Result4    

Remove Element from a Queue in Java

Samual Sam
Updated on 25-Jun-2020 10:35:55

3K+ Views

To remove an element from a Queue, use the remove() method.First, set a Queue and insert some elements −Queue q = new LinkedList(); q.offer("abc"); q.offer("def"); q.offer("ghi"); q.offer("jkl"); q.offer("mno"); q.offer("pqr"); q.offer("stu"); q.offer("vwx");Remove the first element −System.out.println("Queue head = " + q.element()); System.out.println("Removing element from queue = " + q.remove());The following is an example −Example Live Demoimport java.util.LinkedList; import java.util.Queue; public class Demo {    public static void main(String[] args) {       Queue q = new LinkedList();       q.offer("abc");       q.offer("def");       q.offer("ghi");       q.offer("jkl");       q.offer("mno");       q.offer("pqr"); ... Read More

Advertisements