MySQL Datatype to Store Month and Year Only

George John
Updated on 29-Jun-2020 08:12:26

6K+ Views

You need to store the date as the complete date time rather than storing only month and year. If you declare as a datetime then you can extract the month and year using MONTH() and YEAR() function from MySQL.The syntax is as follows −select MONTH(yourDateTimeColumnName) as anyVariableName1, YEAR(yourDateTimeColumnName) as anyVariableName2 from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table OnlyMonthandYear    -> (       -> DueDateTime datetime    -> ); Query OK, 0 rows affected (0.56 sec)Insert date in the table using insert command. ... Read More

Simulate Print Statement in MySQL

Chandu yadav
Updated on 29-Jun-2020 08:11:52

10K+ Views

To simulate a print statement in MySQL, you can use select statement. The syntax is as follows −SELECT ‘anyStringValue’ as ’ ‘;You can check the above syntax at the MySQL command line client.Case 1To print a string.mysql> select 'HELLO MYSQL' as ' ';Output+-------------+ |             | +-------------+ | HELLO MYSQL | +-------------+ 1 row in set (0.00 sec)Case 2a) To print integer, use the following query −mysql> select 23 as ' ';Output+----+ |    | +----+ | 23 | +----+ 1 row in set (0.00 sec)b) To print float or double type, use the following ... Read More

Get the Intersection of Two Sets in Java

Samual Sam
Updated on 29-Jun-2020 08:07:56

15K+ Views

To get the intersection of two sets, use the retainAll() method. Here are out two set −First set −HashSet set1 = new HashSet (); set1.add("Mat"); set1.add("Sat"); set1.add("Cat");Second set −HashSet set2 = new HashSet (); set2.add("Mat"); set2.add("Cat"); set2.add("Fat"); set2.add("Hat");Get the intersection −set1.retainAll(set2);The following is an example to get the intersection of two sets −Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       HashSet set1 = new HashSet ();       HashSet set2 = new HashSet ();       set1.add("Mat");       set1.add("Sat");       set1.add("Cat"); ... Read More

Set Border Image as Rounded, Repeated, and Stretched with CSS

mkotla
Updated on 29-Jun-2020 08:04:38

280 Views

The border-image-repeat property is used to set the border image as rounded, repeated and stretched with CSS.ExampleYou can try to run the following code to implement the border-image-repeat property:Live Demo                    #borderimg1 {             border: 15px solid transparent;             padding: 15px;             border-image-source: url(https://tutorialspoint.com/css/images/border.png);             border-image-repeat: round;             border-image-slice: 40;             border-image-width: 20px;          }                     This is image border example.    

Avoid Placing Password on Command Line with MySQL Utilities

Anvi Jain
Updated on 29-Jun-2020 08:04:20

226 Views

First you need to reach the location of “my.cnf” with the help of below query for MySQL Utilities. The query is as follows −mysql> select @@datadir;The following is the output that display where “my.conf” is −+---------------------------------------------+ | @@datadir                                   | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)Follow the above path in order to open the “my.cnf” file. The snapshot of “my.cnf” location is as follows −Now you can put the below MySQL Utilities in my.cnf which is as ... Read More

Resolve Error 1115: Unknown Character Set 'utf8mb4'

Jennifer Nicholas
Updated on 29-Jun-2020 08:03:49

6K+ Views

You will get this type of error when your MySQL version is below 5.5.3. This is because “utf8mb4” introduced in MySQL version 5.5.3.Firstly, you need to check the current version. If its less than 5.5.3, then you need to upgrade to solve the above error.Check the current version −mysql> select version();Here, our MySQL version is over 5.5.3 −+-----------+ | version() | +-----------+ | 8.0.12    | +-----------+ 1 row in set (0.00 sec)Now the same query that gave an error 1115, will display correct result. To check all character set in MySQL now, use the below query.mysql> show character set;The ... Read More

CSS Border Image Property

seetha
Updated on 29-Jun-2020 08:03:34

99 Views

CSS border-image property is used to add image border to some elements. You can try to run the following code to implement the border-image property −ExampleLive Demo                    #borderimg1 {             border: 15px solid transparent;             padding: 15px;             border-image: url(https://tutorialspoint.com/css/images/border.png) 50 round;          }                     This is image border example.    

Tada Animation Effect with CSS

Anvi Jain
Updated on 29-Jun-2020 08:01:06

489 Views

To create Tada animation effect with CSS, you can try to run the following code:ExampleLive Demo                    .animated {             background-image: url(/css/images/logo.png);             background-repeat: no-repeat;             background-position: left top;             padding-top:95px;             margin-bottom:60px;             -webkit-animation-duration: 10s;             animation-duration: 10s;            -webkit-animation-fill-mode: both;             animation-fill-mode: both;          }          @-webkit-keyframes tada {             0% {-webkit-transform: scale(1);}             10%, 20% {-webkit-transform: scale(0.9) rotate(-3deg);}             30%, 50%, 70%, 90% {-webkit-transform: scale(1.1) rotate(3deg);}             40%, 60%, 80% {-webkit-transform: scale(1.1) rotate(-3deg);}             100% {-webkit-transform: scale(1) rotate(0);}          }          @keyframes tada {             0% {transform: scale(1);}             10%, 20% {transform: scale(0.9) rotate(-3deg);}             30%, 50%, 70%, 90% {transform: scale(1.1) rotate(3deg);}             40%, 60%, 80% {transform: scale(1.1) rotate(-3deg);}             100% {transform: scale(1) rotate(0);}          }          .tada {             -webkit-animation-name: tada;             animation-name: tada;          }                           Reload page                function myFunction() {             location.reload();          }          

Swing Animation Effect with CSS

Samual Sam
Updated on 29-Jun-2020 08:00:14

723 Views

The swing animation effect move or cause to move back and forth or from side to side while suspended or on an axis to an element.ExampleLive Demo                    .animated {             background-image: url(/css/images/logo.png);             background-repeat: no-repeat;             background-position: left top;             padding-top:95px;             margin-bottom:60px;             -webkit-animation-duration: 10s;             animation-duration: 10s;             ... Read More

Subtract 3 Hours from a Datetime in MySQL

Vrundesha Joshi
Updated on 29-Jun-2020 07:53:22

4K+ Views

Subtract 3 hours from DateTime in MySQL, using any of the following ways. The first approach is as follows −Case 1 − Using DATE_ADD()select date_add(yourColumnName, interval -3 hours) from yourTableName;Case 2 − Using DATE_SUB()select date_sub(yourColumnName, interval 3 hours) from yourTableName;Firstly, use now() to get the current date-time −mysql> select now();The following is the output −+---------------------+ | now()               | +---------------------+ | 2018-11-30 10:13:23 | +---------------------+ 1 row in set (0.00 sec)DATE_ADDThe query to subtract 3 hours from DateTime is as follows. With date_add, we have set a negative date −mysql> select date_add(now(), interval -3 ... Read More

Advertisements