Ankith Reddy has Published 996 Articles

Calculate age from date of birth in MySQL?

Ankith Reddy

Ankith Reddy

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

886 Views

To calculate age from date of birth, you can use the below syntax −select timestampdiff(YEAR, yourColumnName, now()) AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentDOB datetime ); Query OK, 0 rows affected (0.61 sec)Insert ... Read More

Convert number INT in minutes to TIME in MySQL?

Ankith Reddy

Ankith Reddy

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

7K+ Views

To convert number INT in minutes to TIME in MySQL, you can use SEC_TO_TIME() function.The syntax is as followsselect SEC_TO_TIME(yourIntColumnName*60) AS `anyAliasName` from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table convertNumberToMinute    -> (    -> ... Read More

How to drop a numeric collection from MongoDB?

Ankith Reddy

Ankith Reddy

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

166 Views

In order to remove the numeric collection name, use the following syntaxdb.getCollection("yourNumericCollectionName").drop();First, create a numeric collection. Following is the query> db.createCollection("2536464"); { "ok" : 1 }Now insert some documents in the above collection. Following is the query> db.getCollection("2536464").insertOne({"Record":1}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca254a46304881c5ce84b8e") } > db.getCollection("2536464").insertOne({"Record":2}); ... Read More

C program to print digital clock with current time

Ankith Reddy

Ankith Reddy

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

3K+ Views

In this section we will see how to make a digital clock using C. To work with time we can use the time.h header file. This header file has some function signatures that are used to handle date and time related issues.The four important components of time.h is like belowsize_t ... Read More

How to read form data using JSP via POST Method?

Ankith Reddy

Ankith Reddy

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

3K+ Views

Below is the main.jsp JSP program to handle the input given by web browser using the GET or the POST methods.Infact there is no change in the above JSP because the only way of passing parameters is changed and no binary data is being passed to the JSP program. File ... Read More

Get the sum of multiple row (not all) values from a MySQL table?

Ankith Reddy

Ankith Reddy

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

914 Views

You can use aggregate function SUM() from MySQL for this. Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Amount int ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert ... Read More

How to use a filter in JSP?

Ankith Reddy

Ankith Reddy

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

668 Views

Following example shows how to print the client's IP address and the current date time, each time it would access any JSP file. This example will give you a basic understanding of the JSP Filter, but you can write more sophisticated filter applications using the same concept −// Import required ... Read More

Floor the decimal values in MySQL instead of round?

Ankith Reddy

Ankith Reddy

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

168 Views

You can use TRUNCATE() method to floor the values instead of round. Let us first create a table −mysql> create table DemoTable (    Value DECIMAL(20, 8) ); Query OK, 0 rows affected (0.54 sec)Insert records in the table using insert command −mysql> insert into DemoTable values(23.5654433); Query OK, 1 ... Read More

How can I profile C++ code running on Linux?

Ankith Reddy

Ankith Reddy

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

475 Views

In Linux platform there are many great profiling tools for profiling C++ programs. Valgrind is one of them. It is widely used. It is a programming tool for memory debugging, memory leak detection, and profiling. We can use Valgrind by passing the binary to it and setting the tool to ... Read More

The contains() method of CopyOnWriteArrayList in Java

Ankith Reddy

Ankith Reddy

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

137 Views

The contains() method of the CopyOnWriteArrayList class is used to get the specified element. It returns TRUE if the element is in the List, else FALSE is returned.The syntax is as followsboolean contains(Object ob)Here, ob is the element to be checked for existence. To work with CopyOnWriteArrayList class, you need ... Read More

Advertisements