In this tutorial, you have learned how to use the SQLite strftime() function to format a datetime value based on a specified format. The following example returns the current Unix timestamp: SELECT strftime( '%s', 'now') Įxtracting day from a date time: SELECT strftime( '%d', '') Įxtracting month from a date time: SELECT strftime( '%m', '') Įxtracting year from a date time: SELECT strftime( '%Y', '') Įxtracting hour from a time value: SELECT strftime( '%H', '10:20:30') Įxtracting minute from a time value: SELECT strftime( '%M', '10:20:30') Įxtracting second from a time value: SELECT strftime( '%S', '10:20:30') Note that all other date and time functions such as date(), time(), datetime(), and julianday() can be expressed using the strftime() function: Function The following table shows the complete list of valid markers for constructing format: Format The strftime() can take one or more modifiers. Prior to SQLite version 3.8.2 (), casting a REAL value. The order of transformation is from left to right. If a REAL is greater than the greatest possible signed integer (+9223372036854775807) then the result is the greatest possible signed integer and if the REAL is less than the least possible signed integer (-9223372036854775808) then the result is the least possible signed integer. Each modifier applies a transformation to the date time value on its left.For example, the now time string returns the current date and time in UTC. time_string specifies the date and time value.format_string specifies the format for the datetime value specified by the time_string value.The following shows the syntax of the strftime() function: strftime(format_string, time_string )Ĭode language: SQL (Structured Query Language) ( sql ) The strftime() function is used to format a datetime value based on a specified format. Overview of the SQLite strftime() function Summary: in this tutorial, you have learned how to use the SQLite strftime() function to format a datetime value based on a specific format.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |