Convert MM-DD-YY to Unix Timestamp in MySQL

Chandu yadav
Updated on 30-Jul-2019 22:30:26

411 Views

To convert MM/DD/YY to UNIX timestamp, you can use the below syntax −select UNIX_TIMESTAMP(str_to_date(yourColumnName, '%m/%d/%Y')) from yourTableName;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    dateConvertToUnix varchar(100)    ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(dateConvertToUnix) values('01/10/2001'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(dateConvertToUnix) values('03/31/2010'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(dateConvertToUnix) values('12/31/2016'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(dateConvertToUnix) values('04/27/2019'); Query OK, 1 ... Read More

Get Combined Field Result in MySQL

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

161 Views

You can use CONCAT() function from MySQL for this. Let us first create a table −mysql> create table DemoTable    (    ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientFirstName varchar(20),    ClientLastName varchar(20)    ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Smith'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('John', 'Miller'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(ClientFirstName, ClientLastName) values('Carol', 'Taylor'); Query OK, 1 row affected (0.13 sec) mysql> insert into ... Read More

Align Multiple Buttons with Different Height in Java

Smita Kapse
Updated on 30-Jul-2019 22:30:26

566 Views

To align multiple buttons with different height in Java, try the following example, Here, we have set 5 buttons with GridBagConstraints −GridBagConstraints constraints = new GridBagConstraints(); constraints.insets = new Insets(5, 5, 5, 5); constraints.anchor = GridBagConstraints.WEST;In addition, to set different height for different buttons, we have used −component. getPreferredSize().heightThe following is an example to align multiple buttons with different height −Examplepackage my; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo {    public static void main(String[] args) {       final JFrame frame = new JFrame(SwingDemo.class.getSimpleName());       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       JPanel panel = new JPanel(new GridBagLayout());       GridBagConstraints constraints = new GridBagConstraints();       constraints.insets = new Insets(5,  5,  5,  5);       constraints.anchor = GridBagConstraints.WEST;     ... Read More

Add Two Consecutive Bytes of an Array in 8085

Chandu yadav
Updated on 30-Jul-2019 22:30:26

835 Views

Here we will see how we can add two consecutive elements in an array using 8085.Problem StatementWrite 8085 program to add two consecutive elements of an array and store them in the same location. The carry will be placed at bottom of the other byte. The numbers are stored from location 8001. The size of array is stored at 8000.DiscussionHere we will solve this problem by using one subroutine. That will add two consecutive numbers and stored them into correct position. That subroutine will be called multiple times to add all consecutive pairs. The task will be followed half of ... Read More

Get First Two Highest Column Values from a Table in MySQL

Kumar Varma
Updated on 30-Jul-2019 22:30:26

496 Views

To get the first two highest columns, use ORDER BY. With that, use LIMIT 2 to get only the first 2 −select *from yourTableName order by yourColumnName DESC LIMIT 2;Let us first create a table −mysql> create table DemoTable    -> (    -> Value int    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(90); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(70); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected ... Read More

HTML DOM Input datetime-local max Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

138 Views

The HTML DOM Input DatetimeLocal max property returns/sets max attribute of Input DatetimeLocal.SyntaxFollowing is the syntax −Returning string valueinputDatetimeLocalObject.maxSetting max to string valueinputDatetimeLocalObject.max = YYYY-MM-DDThh:mm:ssString ValuesHere, “YYYY-MM-DDThh:mm:ss” can be the following −stringValueDetailsYYYYIt defines year (eg:2006)MMIt defines month (eg: 06 for June).DDIt defines Day (eg: 17)TIt is a separator for date and timehhIt defines hour (eg:02)mmIt defines minutes (eg:21)ssIt defines seconds (eg:40)ExampleLet us see an example of Input DatetimeLocal max property − Live Demo Input DatetimeLocal max    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * ... Read More

HTML DOM kbd Object

AmitDiwan
Updated on 30-Jul-2019 22:30:26

124 Views

The Kbd Object represents an inline element which displays monospace font by default.SyntaxFollowing is the syntax −Creating a elementvar kbdObject = document.createElement(“KBD”)ExampleLet us see an example for Kbd object element − Live Demo Kbd Object    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } Kbd Object Keyboard Input:    var divDisplay = document.getElementById("divDisplay");    var textSelect = document.getElementById("textSelect");    function convertKBD() {       var kbdObject = document.createElement("KBD");       var kbdText = document.createTextNode(textSelect.value);       kbdObject.appendChild(kbdText);       divDisplay.appendChild(kbdObject);    } OutputThis will produce the following output −Before clicking ‘Check’ button −After clicking ‘Check’ button −

Get Primary Key Column Name of a Specific Table in MySQL

George John
Updated on 30-Jul-2019 22:30:26

950 Views

Let us first create a table wherein we have a Primary Key CustomerId −mysql> create table DemoTable    (    CustomerId int NOT NULL AUTO_INCREMENT,    CustomerName varchar(20),    CustomerAge int,    CustomerCountryName varchar(100),    PRIMARY KEY(CustomerId)    ); Query OK, 0 rows affected (0.94 sec)Following is the query to get the primary key “column name” of a specific table in MySQL −mysql> SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME = 'DemoTable' AND CONSTRAINT_NAME = 'PRIMARY';This will produce the following output −+-------------+ | COLUMN_NAME | +-------------+ | CustomerId | +-------------+ 1 row in set, 2 warnings (0.12 sec)

Java ResultSet getRow() Method with Example

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

8K+ Views

When we execute certain SQL queries (SELECT query in general) they return tabular data.The java.sql.ResultSet interface represents such tabular data returned by the SQL statements.i.e. the ResultSet object holds the tabular data returned by the methods that execute the statements which quires the database (executeQuery() method of the Statement interface in general).The ResultSet object has a cursor/pointer which points to the current row. Initially this cursor is positioned before first row.The getRow() method of the ResultSet interface retrieves the current row number/position of the ResultSet pointer.This method returns an integer value representing the current row number to which the ResultSet pointer points to.ExampleLet us ... Read More

Using New Line Separator with GROUP_CONCAT Function in MySQL

Anvi Jain
Updated on 30-Jul-2019 22:30:26

2K+ Views

To use new line separator in group_concat() function, follow the below syntax −select group_concat(concat_ws(' ', yourColumnName1, yourColumnName2) SEPARATOR "\r") from yourTableName;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(20),    LastName varchar(20)    ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName, LastName) values('John', 'Smith'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable(FirstName, LastName) values('David', 'Miller'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(FirstName, LastName) values('John', 'Doe'); ... Read More

Advertisements