How to find out number of days in a month in MySQL?

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

5K+ Views

To find the number of days in month, use the below syntax.select DAY(LAST_DAY(yourColumnName)) as anyVariableName from yourTableName;To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table DaysInaGivenMonth -> ( -> MonthName datetime -> ); Query OK, 0 rows affected (1.62 sec)Insert some records in the table using insert command. The query is as follows.mysql> insert into DaysInaGivenMonth values(now()); Query OK, 1 row affected (0.24 sec) mysql> insert into DaysInaGivenMonth values(date_add(now(), interval -1 month)); Query OK, 1 row affected (0.16 sec) mysql> insert into DaysInaGivenMonth values(date_add(now(), interval ... Read More

Why don’t we create green top pitches in India?

Diler Singh
Updated on 30-Jul-2019 22:30:24

477 Views

India-West Indies Test Series is starting from today and so is the debate over green-tops. Undoubtedly, India is a very strong side and have the ability to beat any ferocious opponent on the ground, especially when they play on their home grounds, in India, and in favorable conditions. Similarly, we all know how these home tigers suffer when they land out of the subcontinent. They crash every record of the poor game and impetrate to win a single match out of a series of five.This is what we witnessed in England recently. Not only this time but every time we ... Read More

MySQL update query to remove spaces between letters?

Samual Sam
Updated on 30-Jul-2019 22:30:24

3K+ Views

If you have spaces between letters then you can use REPLACE() function to remove spaces.The syntax is as follows −UPDATE yourTableName SET yourColumnName=REPLACE(yourColumnName, ’ ‘, ’’);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table removeSpaceDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> UserId varchar(20), -> UserName varchar(10), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.81 sec)Now insert some records in the table using insert ... Read More

Java Program to return a Date set to the last possible millisecond of the month before midnight

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24

366 Views

Use the getMaximum() method in Java to returns the maximum value for the given calendar field. We will use it to set the minute, second and millisecond.Let us first declare a calendar object −Calendar dateNoon = Calendar.getInstance();Now, we will set the hour, minute, second and millisecond to the last possible millisecond on the month before midnight.// hour, minute and second calendar.set(Calendar.HOUR_OF_DAY, calendar.getMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getMaximum(Calendar.SECOND)); // millisecond calendar.set(Calendar.MILLISECOND, calendar.getMaximum(Calendar.MILLISECOND));Now, do the following for month and day of month −calendar.set(Calendar.DAY_OF_MONTH, 1); // first day of month calendar.add(Calendar.MONTH, 1); calendar.add(Calendar.DAY_OF_MONTH, -1);The following is an example to return a Date set to ... Read More

8085 program to find 1's and 2's complement of 16-bit number

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:24

3K+ Views

In this program we will see how to find 1's complement and 2's complement of a 16-bit number.Problem StatementWrite 8085 Assembly language program to find 1's complement and 2's complement of a16-bit number stored in 8000H and 8001H.Discussion8085 has an instruction CMA. This instruction complements the content of Accumulator. For 1's complement CMA instruction is sufficient, and for 2's complement we have to increase the number by 1 after complementing.For 16-bit number, we are taking the number into HL pair, but for complementing we have to copy the numbers to Accumulator from H and L one by one. Then by ... Read More

How to get the absolute coordinates of a view in Android?

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

5K+ Views

Before getting into example, we should know what is absolute coordinates. It means absolute position (x, y)of a view on window manager. This example demonstrate about how to get the absolute coordinates of a view.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above xml, we have given one Textview. when user click on textview, it will show the position of the view on Toast.Step 3 − Add the following ... Read More

What is the Babinet’s principle which is the basic for Slot Antenna?

Knowledge base
Updated on 30-Jul-2019 22:30:24

4K+ Views

Babinet’s Principle is actually the principle used in optics. According to its definition, “When the field behind a screen with an opening is added to the field of a complementary structure, the sum is equal to the field when there is no screen”The images clearly explain the principle. In all the regions, which are non-collinear with the beam, the above two screens, in figure 1 & 2, produce the same diffraction pattern.Case1Consider a light source and a conducting plane (field) with an aperture before a screen. The light does not pass through the opaque area but passes through the aperture.Case2Consider ... Read More

How to implement Android TextInputLayout

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

3K+ Views

Before getting into example, we should know what is TextInputLayout in android. TextInputLayout is extended by Linear Layout. It going to act as a wrapper for edit text and shows flatting hint animation for edit text.This example demonstrate about how to implement Android TextInputLayout.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                 In the above code ... Read More

Java Program to return a Date set to the first possible millisecond of the month after midnight

Samual Sam
Updated on 30-Jul-2019 22:30:24

217 Views

Use the getMaximum() method in Java to returns the maximum value for the given calendar field. We will use it to set the minute, second and milliseconds.Let us first declare a calendar object −Calendar dateNoon = Calendar.getInstance();Now, we will set the hour, minute, second and millisecond to the first possible millisecond of the month after midnight −// hour, minute and second calendar.set(Calendar.HOUR_OF_DAY, calendar.getMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getMaximum(Calendar.SECOND)); // millisecond calendar.set(Calendar.MILLISECOND, calendar.getMaximum(Calendar.MILLISECOND));The following is an example that return a Date set to the first possible millisecond of the month after midnight −Example Live Demoimport java.util.Calendar; import java.util.GregorianCalendar; public class Demo { ... Read More

8085 program to find 2's complement of the contents of Flag Register

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

472 Views

In this program we will see how to find 2's complement of the content of flag register.Problem StatementWrite 8085 Assembly language program to find 2's complement of the content of flag register.DiscussionWe cannot access the total flag register directly. To use them we have to push the PSW(Accumulator-Flag) into stack, and then pop it to another register pair, then after complementing the LS byte of that register pair, we have to push it again into the stack, and then pop it to PSW  to get it into Flag bits.InputHere we are not putting any input directly. If the flag bits ... Read More

Advertisements