Stay organized with collections Save and categorize content based on your preferences.
GoogleSQL for Spanner supports the following format elements.
Format elements for date and time partsMany GoogleSQL parsing and formatting functions rely on a format string to describe the format of parsed or formatted values. A format string represents the textual form of date and time and contains separate format elements that are applied left-to-right.
These functions use format strings:
Format strings generally support the following elements:
Format element Type Description Example%A
DATE
TIMESTAMP
Wednesday
%a
DATE
TIMESTAMP
Wed
%B
DATE
TIMESTAMP
January
%b
DATE
TIMESTAMP
Jan
%C
DATE
TIMESTAMP
20
%c
TIMESTAMP
Wed Jan 20 21:47:00 2021
%D
DATE
TIMESTAMP
01/20/21
%d
DATE
TIMESTAMP
20
%e
DATE
TIMESTAMP
20
%F
DATE
TIMESTAMP
2021-01-20
%G
DATE
TIMESTAMP
2021
%g
DATE
TIMESTAMP
21
%H
TIMESTAMP
21
%h
DATE
TIMESTAMP
Jan
%I
TIMESTAMP
09
%j
DATE
TIMESTAMP
020
%k
TIMESTAMP
21
%l
TIMESTAMP
9
%M
TIMESTAMP
47
%m
DATE
TIMESTAMP
01
%n
All A newline character. %P
TIMESTAMP
pm
%p
TIMESTAMP
PM
%Q
DATE
TIMESTAMP
1
%R
TIMESTAMP
21:47
%S
TIMESTAMP
00
%s
TIMESTAMP
1611179220
%T
TIMESTAMP
21:47:00
%t
All A tab character. %U
DATE
TIMESTAMP
03
%u
DATE
TIMESTAMP
3
%V
DATE
TIMESTAMP
03
%W
DATE
TIMESTAMP
03
%w
DATE
TIMESTAMP
3
%X
TIMESTAMP
21:47:00
%x
DATE
TIMESTAMP
01/20/21
%Y
DATE
TIMESTAMP
2021
%y
DATE
TIMESTAMP
21
%Z
TIMESTAMP
UTC-5
%z
TIMESTAMP
-0500
%%
All A single % character. %
%Ez
TIMESTAMP
-05:00
%E<number>S
TIMESTAMP
00.000 for %E3S
%E*S
TIMESTAMP
%E4Y
DATE
TIMESTAMP
2021
Examples:
SELECT FORMAT_DATE("%b-%d-%Y", DATE "2008-12-25") AS formatted;
/*-------------*
| formatted |
+-------------+
| Dec-25-2008 |
*-------------*/
SELECT FORMAT_TIMESTAMP("%b %Y %Ez", TIMESTAMP "2008-12-25 15:30:00+00")
AS formatted;
/*-----------------*
| formatted |
+-----------------+
| Dec 2008 +00:00 |
*-----------------*/
SELECT PARSE_DATE("%Y%m%d", "20081225") AS parsed;
/*------------*
| parsed |
+------------+
| 2008-12-25 |
*------------*/
SELECT PARSE_TIMESTAMP("%c", "Thu Dec 25 07:30:00 2008") AS parsed;
-- Display of results may differ, depending upon the environment and
-- time zone where this query was executed.
/*------------------------*
| parsed |
+------------------------+
| 2008-12-25T15:30:00Z |
*------------------------*/
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4