Daniol Thomas has Published 209 Articles

How to sort inner array in MongoDB?

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

3K+ Views

You can achieve this with the help of aggregate framework in MongoDB. To understand it, let us create a collection with document. The query to create a collection with document is as follows:> db.sortInnerArrayDemo.insertOne( ... ...    { ...       "EmployeeDetails": ...       { ...   ... Read More

Period getDays() method in Java

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

279 Views

The number of days for a particular Period can be obtained using the getDays() method in the Period class in Java. This method requires no parameters and it returns the number of days in the Period.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { ... Read More

Period getMonths() method in Java

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

90 Views

The number of months for a particular Period can be obtained using the getMonths() method in the Period class in Java. This method requires no parameters and it returns the number of months in the Period.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { ... Read More

Period getYears() method in Java

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

171 Views

The number of years for a particular Period can be obtained using the getYears() method in the Period class in Java. This method requires no parameters and it returns the number of years in the Period.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { ... Read More

Period isZero() method in Java

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

111 Views

It can be checked if the days, months and years in the Period are zero or not using the isZero() method in the Period class in Java. This method requires no parameters. Also, it returns true if the days, months and years in the Period are zero and false otherwise.A ... Read More

How can I count the number of days in MySQL?

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

348 Views

Let us first create a table with one column as datetime and another wherein the days are stored:mysql> create table DemoTable (    ShippingDate datetime,    CountOfDate int ); Query OK, 0 rows affected (0.52 sec)Following is the query to insert some records in the table using insert command:mysql> insert ... Read More

How to use COUNT(*) to return a single row instead of multiple?

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

710 Views

You need to use GROUP BY with COUNT(*) for this to group the values and display the count eliminating multiple values. Let us first create a table:mysql> create table DemoTable (Value int); Query OK, 0 rows affected (0.55 sec)Following is the query to insert some records in the table using ... Read More

Get today's date in (YYYY-MM-DD) format in MySQL?

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

3K+ Views

To get today’s date in (YYYY-MM-DD) format in MySQL, you can use CURDATE().Following is the query to get the current date:mysql> SELECT CURDATE();This will produce the following output:+------------+ | CURDATE() | +------------+ | 2019-04-09 | +------------+ 1 row in set (0.00 sec)You can also use NOW() for this. Following ... Read More

MySQL query to get substrings (only the last three characters) from strings?

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

198 Views

For this, you can use SUBSTR() method. Let us first create a table:mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(20)); Query OK, 0 rows affected (1.31 sec)Following is the query to insert some records in the table using insert command:mysql> insert into ... Read More

Period between() method in Java

Daniol Thomas

Daniol Thomas

Updated on 30-Jul-2019 22:30:25

3K+ Views

The Period between two dates can be obtained using the between() method in the Period class in Java. This method requires two parameters i.e. the start date and the end date and it returns the Period between these two dates.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; ... Read More

Advertisements