We can use MySQL’s LAST_DAY()
function to return the last day of a given month.
This could be the last day of the current month, or the last day of the month based on a date that we specify.
Continue readingWe can use MySQL’s LAST_DAY()
function to return the last day of a given month.
This could be the last day of the current month, or the last day of the month based on a date that we specify.
Continue readingWhen using one of SQLite’s tabular output modes, you can enable the --wrap
option in order to limit the width of each column. This can be handy when the data contains long lines of text.
When we do this, we have the option of specifying “word wrap”, so that words don’t get cut off halfway through.
There are two ways to specify word wrap: use --wordwrap on
or its shortcut -ww
.
Here’s an example of using PostgreSQL to return the number of days in a month, based on a given date.
Continue readingIn PostgreSQL, we can use the upper()
function to convert lowercase characters to their uppercase equivalent, according to the rules of the database’s locale.
In PostgreSQL, we can use the lower()
function to convert uppercase characters to their lowercase equivalent, according to the rules of the database’s locale.
We can use the following method in PostgreSQL to return the first day of a given month.
This could be the first day of the current month, or the first day of the month based on a date that we specify.
Getting the first day of the month allows us to perform further calculations on the resulting date, like adding a certain number of days to the start of the month, etc.
Continue readingBelow are two options for finding those rows that only contain non-alphanumeric characters in MySQL.
Non-alphanumeric characters include punctuation characters like !@#&()–[{}]:;',?/*
and symbols like `~$^+=<>“
, as well as whitespace characters like the space or tab characters.
In PostgreSQL, we can use the +
operator to add one or more hours to a time value.
By “time” value, this could be an actual time
value, a timestamp
, or an interval
. We can also add hours to a date
value or a date
and time
combination.
If you’re getting “Error: in prepare, SELECTs to the left and right of UNION do not have the same number of result columns…” in when trying to use the UNION
operator in SQLite, it’s because one of the SELECT
statements is returning more columns than the other.
If you need to calculate the number of seconds that have passed since a given date and time, you can use the UNIXEPOCH()
function.
Note that this function was introduced in SQLite 3.38.0, so it will only work if you’re using SQLite 3.38.0 or later.
Continue reading