About the use of strftime

Source: Internet
Author: User
Tags current time local time month name sqlite sqlite database

Strftime is a computer function in which the strftime () function formats the local time/date according to locale, and the function formats the time, or formats a time string.

Self-understanding can be used in C language based language, such as C C + + SQLite database

The following copy is from: http://baike.baidu.com/view/1284677.htm

(Baidu Encyclopedia) a section on the strftime of the detailed

Parameter description:

We can place the time information stored in the timeptr in the strdest-pointing string according to the format pointing to the Formatting command in the string, and maxsize characters to the strdest. The function returns the number of characters placed in the string pointed to strdest.

The operation of the function strftime () is somewhat similar to the sprintf (): The collection of format commands that begin with the percent sign (%) is recognized, and the formatted output is placed in a string. The format command describes the exact representation of the various date and time information in the string strdest. Other characters in the format string are placed in the string as is. The formatting commands are listed below, and they are case-sensitive.

%a Day of the week

%A the full name of the week

%b of the Month

Full name of%B month

Time series for the%c standard date

Rear two digits of%c year

The first day of the month in%d decimal notation

%d Month/day/year

%e in a two-character field, the first day of the month in decimal notation

%F year-month-day

Two digits of%g year, using week-based years

%G years, using weeks based

%h Abbreviated month name

%H 24-hour system hours

%I 12-hour hours

%j decimal representation of the first day of the year

Month in%m decimal notation

Number of minutes represented by%m 10 o'clock

%n New Line character

%p the equivalent display of a local AM or PM

%r 12 hours.

%R display hours and minutes: hh:mm

%s decimal number of seconds

%t Horizontal Tab

%T when displayed: Hh:mm:ss

%u days of the week, Monday is the first day (values from 0 to 6, Monday to 0)

%u week of the year, make Sunday the first day (values from 0 to 53)

%V the first weeks of the year, using a week based year

%w decimal representation of the week (values from 0 to 6, Sunday to 0)

%w Week of the year, Monday is the first day (value from 0 to 53)

The date string of the%x standard

%x Standard Time series

%y decimal Year without century (values from 0 to 99)

%Y 10 year of the century part

%z,%z the time zone name and returns a null character if the time zone name cannot be obtained.

Percent percent%

Grammar

Strftime (format,timestamp) parameter description

Format is optional. Specify how the results are returned.

Timestamp optional.

Tips and comments

Hint: the same behavior as Gmstrftime (), and the difference is that the return time is local time.

SQLite Use examples:

SELECT strftime ('%y%m ', d_order_date) from Tbl_order

My computer's current time is: June 19, 2011 17:18:57

The above SQL statement returns a result of 201106

With such a result, we will be convenient as a condition to judge and so on to bring more convenience

Such as:

SELECT * from Table WHERE strftime('%y%m ', d_date) = ' 201106 '

The above for personal understanding, I hope everyone a lot of guidance.

Strftime has only been tested in SQLite.


Reference: Http://www.wxzzz.com/Program/strftime

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.