In SQL Server you can use the FOR JSON
clause in a query to format the results as JSON. When doing this, you must choose either the AUTO
or the PATH
option. This article contains examples of using the AUTO
option.
Tag: functions
ORD() Examples – MySQL
In MySQL, the ORD()
function returns the numeric value of the leftmost character of a given string. You provide the string as an argument.
If the leftmost character is a multibyte character, the returned value is calculated from the numeric values of its constituent bytes. If the leftmost character is not a multibyte character, the return value is its ASCII code (which is the same result as when using the ASCII()
function).
ASCII() Examples – MySQL
In MySQL, the ASCII()
function returns the numeric ASCII code of the leftmost character of a given string. You provide the string as an argument.
This article contains examples of usage.
YEARWEEK() Examples – MySQL
In MySQL, the YEARWEEK()
function returns the year and week for a given date. You provide the date as an argument, and the function will return the result accordingly.
You also have the option of specifying whether to start the week on Sunday or Monday, and whether the week should be in the range 0 to 53 or 1 to 53.
WEEKOFYEAR() Examples – MySQL
In MySQL, you can use the WEEKOFYEAR()
function to return the calendar week for a given date. Simply provide the date as an argument and the function will return the calendar week as a number in the range from 1 to 53.
WEEKDAY() Examples – MySQL
In MySQL, you can use the WEEKDAY()
function to return the weekday index for a given date. Simply provide the date as an argument and the function will return the weekday index.
WEEK() Examples – MySQL
In MySQL, you can use the WEEK()
function to get the week number for a given date. By “week number” I mean the week of the year.
To use the function, simply provide the date as an argument and the week number will be returned.
You also have the option of specifying whether to start the week on Sunday or Monday, and whether the week should be in the range 0 to 53 or 1 to 53.
UTC_TIMESTAMP() Examples – MySQL
In MySQL, you can use the UTC_TIMESTAMP
function to return the UTC date and time. UTC stands for Coordinated Universal Time and it’s the primary time standard by which the world regulates clocks and time.
The result of this function is returned either in ‘YYYY-MM-DD HH:MM:SS’ or YYYYMMDDHHMMSS format, depending on whether it’s used in a string or numeric context.
UTC_TIME Examples – MySQL
In MySQL, you can use the UTC_TIME
function to return the UTC time. UTC stands for Coordinated Universal Time and it’s the primary time standard by which the world regulates clocks and time.
The result is returned either in ‘HH:MM:SS’ or HHMMSS format, depending on whether the function is used in a string or numeric context.
UTC_DATE Examples – MySQL
In MySQL, you can use the UTC_DATE
function to return the UTC date. UTC stands for Coordinated Universal Time and it’s the primary time standard by which the world regulates clocks and time.
The result is returned either in ‘YYYY-MM-DD’ or YYYYMMDD format, depending on whether the function is used in a string or numeric context.