As we know that this function converts a number of seconds into TIMESTAMP value. So by providing 0 seconds as the argument, it will give us the starting range of TIMESTAMP data type.mysql> Select FROM_UNIXTIME(0); +-------------------------+ | FROM_UNIXTIME(0) | +-------------------------+ | 1970-01-01 05:30:00 | +-------------------------+ 1 row in set (0.00 sec)Now if we will change the argument from 0 to 60 seconds then the time will be changed by 01 minutes.mysql> Select FROM_UNIXTIME(60); +-------------------------+ | FROM_UNIXTIME(60) | +-------------------------+ | 1970-01-01 05:31:00 | +-------------------------+ 1 row in set (0.00 sec)
Every time a new app is launched or say a new version of existing app is launched, our Android smartphone gives us the notification, New updates are available or updated your phone etc. For any techie, developer or mobile lover it is the most beautiful feeling. They are too excited to try the new version.But for the rest of us, we are like why we don’t need any update or I am too lazy for all these things. But that’s the case we can’t help, so either we update and enjoy we features with of course some faults, missing our ... Read More
Comparison operator between dates will work in a logical way. In the following example, while comparing two dates, MySQL is simply comparing two numbers or string −mysql> select 20171027 < 20150825; +---------------------------+ | 20171027 < 20150825 | +---------------------------+ | 0 | +---------------------------+ 1 row in set (0.00 sec)The 0 output shows that the result of the above query is FALSE.mysql> select 20171027 > 20150825; +--------------------------+ | 20171027 > 20150825 | +--------------------------+ | 1 | +--------------------------+ 1 row in set (0.00 sec)The output ‘1’ shows that the result of the above query is TRUE.
Such kind of calculations can cause unpredictable result because when the date is represented as MySQL string then MySQL tries to perform numeric operations on a string by taking only the first that appears. Following examples will clarify it −mysql> select '2017-10-17' + 20; +-------------------+ | '2017-10-17' + 20 | +-------------------+ | 2037 | +-------------------+ 1 row in set, 1 warning (0.00 sec) mysql> select '2017-10-25' - 17; +-------------------+ | '2017-10-25' - 17 | +-------------------+ | 2000 | +-------------------+ 1 row in set, 1 warning (0.00 sec) ... Read More
We can display the name of MySQL database that is currently in use by Select Database() command.mysql> select database(); +------------+ | database() | +------------+ | tutorial | +------------+ 1 row in set (0.00 sec)This command shows that we currently use tutorial database.
With the help of CREATE DATABASE db-name command, we can check the statement of creating any MySQL database.mysql> SHOW CREATE DATABASE Sample; +----------+-------------------------------------------------------------------+ | Database | Create Database | +----------+-------------------------------------------------------------------+ | sample | CREATE DATABASE `sample` /*!40100 DEFAULT CHARACTER SET latin1 */ | +----------+-------------------------------------------------------------------+ 1 row in set (0.00 sec)The output shows how MySQL database named Sample has been created.
When it comes to two of the most talked about technologies in present times, Big Data and Internet of Things (IoT) are perhaps right at the helm. And over the last few years, Big Data has made progress in numerous domains. And although Internet of Things happens to be different, it is massively linked to Big Data.What is Big Data?Big Data is essentially a large amount of data that is in complex form. Specifically, it also refers to the use of predictive analysis and methods that allows extraction of valuable information from such data. This allows better decision making, reduction ... Read More
In DATEDIFF() function only the date parts of the values are used in calculation hence we can use TIMESTAMPDIFF() function to calculate full 24 hour days between two specified dates.For example, if we want to find full 24hour days between ‘2017-05-27 11:59:00’ and 2017-05-23 12:00:00’ then following would be MySQL query −mysql> Select TIMESTAMPDIFF(DAY, '2017-05-23 12:00:00' , '2017-05-27 11:59:00'); +---------------------------------------------------------------------------+ | TIMESTAMPDIFF(DAY, '2017-05-23 12:00:00' , '2017-05-27 11:59:00') | +---------------------------------------------------------------------------+ | 3 | +---------------------------------------------------------------------------+ 1 row in set (0.00 sec)
The digital world has always been action packed and aggressively competitive since its existence. With exponentially continuous breakthroughs in the world of science and technology, the tech giants like Microsoft, Google, and Apple have been within a perpetual war against each other and the war doesn’t seem to come to an end in the near future.Unlike other kinds of war, whether real or virtual, instead of destructive consequences, this ‘tech-war’ only has constructive consequences bringing an immense amount of productivity for the end users like me and you. This competition in technology has shaped our present and will define our ... Read More
To store such kind of dates where the day, month or both month & day are zero we must have to set mode of sql to allow_invalid_dates mode.mysql> set sql_mode = 'allow_invalid_dates'; Query OK, 0 rows affected (0.00 sec) mysql> insert into check_date(OrderDate) values('2017-00-00'); Query OK, 1 row affected (0.06 sec) mysql> select * from check_date; +-------------+ | OrderDate | +-------------+ | 2017-00-00 | +-------------+ 1 row in set (0.00 sec)Above query will insert the date in which both month & day values are zero.mysql> insert into check_date(Orderdate) values ('2017-00-05'); Query OK, 1 row affected (0.07 sec) ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP