JavaScript Boolean Function

vineeth.mariserla
Updated on 23-Aug-2019 15:17:10

199 Views

Boolean functionWhile developing, a developer may come across yes/no situation. At that point of time Boolean() function can be used. It results only in true or false. Let's discuss it in detail.syntaxBoolean(exp);It takes an expression and scrutinizes it and displays either true or false based on the validity of the expression.Example-1In the following example, various values have been checked whether they are true or not using Boolean() function. If any value has any legitimate value then it results in true else it results in false.  var a = 0;           ... Read More

Convert MySQL Date Format from yyyy-mm-ddThh:mm:ss.sssZ to yyyy-mm-dd hh:mm:ss

AmitDiwan
Updated on 23-Aug-2019 14:00:12

3K+ Views

Let us first create a table −mysql> create table DemoTable668(JoiningDate varchar(200)); Query OK, 0 rows affected (0.97 sec)Insert some records in the table using insert command. We have inserted date in the format yyyy-mm-ddThh:mm:ss.sssZ −mysql> insert into DemoTable668 values('2001-01-10T06:20:00.000Z'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable668 values('2019-07-20T04:00:00.000Z'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable668 values('2016-02-12T05:10:50.000Z'); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from DemoTable668;This will produce the following output −+--------------------------+ | JoiningDate             | +--------------------------+ | ... Read More

Planar Graphs and Their Properties

Mahesh Parahar
Updated on 23-Aug-2019 13:59:12

6K+ Views

A graph 'G' is said to be planar if it can be drawn on a plane or a sphere so that no two edges cross each other at a non-vertex point.ExampleRegionsEvery planar graph divides the plane into connected areas called regions.ExampleDegree of a bounded region r = deg(r) = Number of edges enclosing the regions r.deg(1) = 3 deg(2) = 4 deg(3) = 4 deg(4) = 3 deg(5) = 8Degree of an unbounded region r = deg(r) = Number of edges enclosing the regions r.deg(R1) = 4 deg(R2) = 6In planar graphs, the following properties hold good −1. In a ... Read More

Pendent Vertex, Isolated Vertex and Adjacency of a Graph

Mahesh Parahar
Updated on 23-Aug-2019 13:22:55

10K+ Views

Pendent VertexBy using degree of a vertex, we have a two special types of vertices. A vertex with degree one is called a pendent vertex.ExampleHere, in this example, vertex 'a' and vertex 'b' have a connected edge 'ab'. So with respect to the vertex 'a', there is only one edge towards vertex 'b' and similarly with respect to the vertex 'b', there is only one edge towards vertex 'a'. Finally, vertex 'a' and vertex 'b' has degree as one which are also called as the pendent vertex.Isolated VertexA vertex with degree zero is called an isolated vertex.ExampleHere, the vertex 'a' ... Read More

MySQL Query to Select Closest Date from Today

AmitDiwan
Updated on 23-Aug-2019 13:19:44

2K+ Views

Let’s say the current date is 2019-07-25. We will now see an example and create a table where ShippingDate is added in the table.Let us first create a table −mysql> create table DemoTable667(ShippingDate datetime); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable667 values('2019-01-31'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable667 values('2019-07-19'); Query OK, 1 row affected (0.69 sec) mysql> insert into DemoTable667 values('2019-07-23'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable667 values('2019-08-24'); Query OK, 1 row affected (0.15 sec)Display all records from ... Read More

Partitioning of a Set

Mahesh Parahar
Updated on 23-Aug-2019 13:18:18

10K+ Views

Partition of a set, say S, is a collection of n disjoint subsets, say P1, P1, ... Pn that satisfies the following three conditions −Pi does not contain the empty set.                        [ Pi ≠ { ∅ } for all 0 < i ≤ n ]The union of the subsets must equal the entire original set.                       [ P1 ∪ P2 ∪ ... ∪ Pn = S ]The intersection of any two distinct sets is empty.            ... Read More

Grant Replication Privilege to a Database in MySQL

AmitDiwan
Updated on 23-Aug-2019 13:15:43

1K+ Views

To grant replication privilege, use GRANT REPLICATION SLAVE ON.First list all the user names along with host from MySQL.user table −mysql> select user, host from mysql.user;This will produce the following output −+------------------+-----------+ | user             | host | +------------------+-----------+ | Bob              | % | | Charlie          | % | | Robert           | % ... Read More

Minimum Spanning Tree Algorithms

Mahesh Parahar
Updated on 23-Aug-2019 13:13:57

5K+ Views

A spanning tree with assigned weight less than or equal to the weight of every possible spanning tree of a weighted, connected and undirected graph $G$, it is called minimum spanning tree (MST). The weight of a spanning tree is the sum of all the weights assigned to each edge of the spanning tree. Following are two most popular algorithms to find a minimum spanning tree (MST).Kruskal's AlgorithmKruskal's algorithm is a greedy algorithm that finds a minimum spanning tree for a connected weighted graph. It finds a tree of that graph which includes every vertex and the total weight of ... Read More

Format MySQL Date and Convert to Year-Month-Day

AmitDiwan
Updated on 23-Aug-2019 13:09:54

523 Views

Let us first create a table −mysql> create table DemoTable666(AdmissionDate varchar(200)); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable666 values('Sat, 20 Jul 2019 04:29:35'); Query OK, 1 row affected (1.12 sec) mysql> insert into DemoTable666 values('Fri, 02 Oct 2018 12:19:15'); Query OK, 1 row affected (1.05 sec) mysql> insert into DemoTable666 values('Sun, 01 Aug 2016 11:10:05'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable666 values('Fri, 06 Nov 2015 04:06:05 -0500'); Query OK, 1 row affected (0.24 sec)Display all records from the table using select statement −mysql> ... Read More

Create a Table in MySQL and Implement TIMESTAMPDIFF

AmitDiwan
Updated on 23-Aug-2019 13:07:24

121 Views

The TIMESTAMPDIFF() calculates the difference between two dates or datetime expressions. Let us first create a table −mysql> create table DemoTable665(    PunchInTime datetime,    PunchOutTime datetime,    Details INT(11) AS (ABS(TIMESTAMPDIFF(second, PunchInTime, PunchOutTime))) )ENGINE=MyISAM; Query OK, 0 rows affected (0.23 sec)Insert some records in the table using insert command −mysql> insert into DemoTable665(PunchInTime, PunchOutTime) values('2019-09-21 9:30:10', '2019-09-21 04:34:56'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable665(PunchInTime, PunchOutTime) values('2019-11-11 10:00:20', '2019-11-11 05:30:16'); Query OK, 1 row affected (0.04 sec)Display all records from the table using select statement −mysql> select *from DemoTable665;This will produce the following output −+---------------------+---------------------+---------+ ... Read More

Advertisements