Skip to Main Content
Using SQLite
book

Using SQLite

by Jay A. Kreibich
August 2010
Intermediate to advanced content levelIntermediate to advanced
526 pages
23h 39m
English
O'Reilly Media, Inc.
Content preview from Using SQLite

Name

strftime() — Decode time string into any format

Common Usage

strftime( format, timestring, modifier1, modifier2, ... )

Description

The strftime() function returns a formatted string by taking a timestring (with modifiers) and formating it according to format , a printf() style format specification. If any of the parameters are in an incorrect or illegal format, a NULL is returned.

The format string can contain any of the following markers:

  • %d — day of the month ( DD ), 01-31

  • %f — seconds with fractional part (SS.sss), 00-59 plus decimal portion

  • %H — hour ( HH ), 00-23

  • %j — day of the year ( NNN ), 001-366

  • %J — Julian Day number (DDDDDDD.ddddddd)

  • %m — month ( MM ), 01-12

  • %M — minute ( MM ), 00-59

  • %s — seconds since 1970-01-01 (Unix epoch)

  • %S — seconds ( SS ), 00-59

  • %w — day of the week ( N ), starting with Sunday as 0

  • %W — week of the year ( WW ), 00-53

  • %Y — year ( YYYY )

  • %% — a literal %

The timestring value can be in any of these formats:

  • YYYY-MM-DD

  • YYYY-MM-DD HH:MM

  • YYYY-MM-DD HH:MM:SS

  • YYYY-MM-DD HH:MM:SS.sss

  • YYYY-MM-DDTHH:MM

  • YYYY-MM-DDTHH:MM:SS

  • YYYY-MM-DDTHH:MM:SS.sss

  • HH:MM

  • HH:MM:SS

  • HH:MM:SS.sss

  • now

  • DDDDDDD

  • DDDDDDD.ddddddd

All hour values use a 24-hour clock. Any value that is not given will be implied. Any implied hour, minute, second, or subsecond is zero. Any implied month or day of month is 1. Any implied year is 2000. The full date and time formats allow either a space or a literal uppercase T between the date and time. The last two values (a single, large integer ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning SQL, 3rd Edition

Learning SQL, 3rd Edition

Alan Beaulieu
High Performance MySQL, 4th Edition

High Performance MySQL, 4th Edition

Silvia Botros, Jeremy Tinley

Publisher Resources

ISBN: 9781449394592Errata PageSupplemental Content