Krantik Chavan has Published 308 Articles

How to order by certain part of a string in MySQL?

Krantik Chavan

Krantik Chavan

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

2K+ Views

You can use ORDER BY SUBSTRING() to order by certain part of a string in MySQL. Let us first create a table:mysql> create table DemoTable (UserId varchar(200)); Query OK, 0 rows affected (0.68 sec)Following is the query to insert records in the table using insert command:mysql> insert into DemoTable values('USER_1234'); ... Read More

Java Program to convert this duration to the total length in nanoseconds

Krantik Chavan

Krantik Chavan

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

112 Views

With this, get the nanoseconds in days, hours and minutes. At first, set the Duration:Duration d1 = Duration.ofDays(5); Duration d2 = Duration.ofHours(20); Duration d3 = Duration.ofMinutes(15);Convert the above Duration to nanoseconds:System.out.println("Nanoseconds in 5 days = "+d1.toNanos()); System.out.println("Nanoseconds in 20 hours = "+d2.toNanos()); System.out.println("Nanoseconds in 15 minutes = "+d3.toNanos());Exampleimport java.time.Duration; public ... Read More

Java Program to create Instant from Epoch second and millisecond

Krantik Chavan

Krantik Chavan

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

989 Views

Create Instant from Epoch SecondExampleimport java.time.Instant; public class Demo {    public static void main(String[] args) {       Instant instant = Instant.ofEpochSecond(282829279);       System.out.println(instant);    } }Output1978-12-18T11:41:19ZCreate Instant from Epoch MillisecondsExampleimport java.time.Instant; public class Demo {    public static void main(String[] args) {       ... Read More

How can I remove every column in a table in MySQL?

Krantik Chavan

Krantik Chavan

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

76 Views

In order to remove every column in a table in MySQL, you can use DROP TABLE command. Following is the syntax:DROP TABLE yourTableName;Let us first create a table:mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFirstName varchar(20),    StudentLastName varchar(20),    StudentAge int,   ... Read More

Java Program to get Epoch seconds from Instant

Krantik Chavan

Krantik Chavan

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

171 Views

Create an Instant and get an Instant using milliseconds passed as parameter from the epoch of 1970-01- 01T00:00:00Z. This is done using ofEpochMilli():Instant instant = Instant.ofEpochMilli(342627282920l);Now, get the Epoch seconds from Instant:instant.getEpochSecond();Exampleimport java.time.Instant; public class Demo {    public static void main(String[] args) {       Instant instant = ... Read More

C++ Program to Generate Random Numbers Using Probability Distribution Function

Krantik Chavan

Krantik Chavan

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

1K+ Views

Probability Density Function (pdf), is a function that describes the relative likelihood for this random variable to take on a given value. It is also called as density of a continuous random variable.The probability of the random variable fall within a particular range of values is given by the integral ... Read More

Java Program to get Milli seconds from Instant

Krantik Chavan

Krantik Chavan

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

176 Views

Create an Instant and get an Instant using milliseconds passed as parameter from the epoch of 1970-01- 01T00:00:00Z. This is done using ofEpochMilli():Instant instant = Instant.ofEpochMilli(342627282920l);Now, get the Epoch milliseconds from Instant:instant. toEpochMilli();Exampleimport java.time.Instant; public class Demo {    public static void main(String[] args) {       Instant instant ... Read More

Can I write my own MySQL functions to use in MySQL queries?

Krantik Chavan

Krantik Chavan

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

345 Views

Yes, you can write own MySQL function to use in MySQL queries. Following is the syntax:DELIMITER // CREATE FUNCTION yourFunctionName(optional parameters)) RETURNS yourDataType DETERMINISTIC NO SQL BEGIN yourStatements1 . . . . N END // DELIMITER ;We have used the CREATE FUNCTION above to create a custom function.Let us create ... Read More

Addressing of I/O Ports in 8085 Microprocessor

Krantik Chavan

Krantik Chavan

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

6K+ Views

The Central Processing Unit and the main memory are always very accurate and fast as compared with electromechanical input or output devices like printers, etc. Here in this case it is essential for us that the data lines of the computer are not engaged for a long time during communication ... Read More

How to get the duration between two Instant timestamps in Java

Krantik Chavan

Krantik Chavan

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

18K+ Views

Let us first set two Instants with ofEpochSeconds() method using seconds from the epoch of 1970-01- 01T00:00:00Z.Now get the duration between the above two Instant:Duration res = Duration.between(one, two);Exampleimport java.time.Duration; import java.time.Instant; public class Demo {    public static void main(String[] args) {       Instant one = Instant.ofEpochSecond(1845836728); ... Read More

Advertisements