Neste exemplo, DateTimeText é um campo que contém uma data e hora em formato de texto. O resultado da aplicação de PARSE_DATETIME com a format_string correta é um valor de "Data e hora".
Exemplo de fórmula
Entrada
Saída
PARSE_DATETIME("%d/%m/%y %H:%M:%S", DateTimeText)
25/12/08 12:12:12
2008-12-25 12:12:12
O exemplo a seguir analisa o campo DateTimeText que contém uma data em um formato de linguagem natural como um valor "Data e hora".
Exemplo de fórmula
Entrada
Saída
PARSE_DATETIME('%A, %B %e, %Y', DateTimeText)
Wednesday, December 19, 2018
2018-12-19 00:00:00
Observações
Ao usar PARSE_DATETIME, tenha em mente o seguinte:
Campos não especificados. Qualquer campo não especificado é inicializado em 1970-01-01.
Nomes que não diferenciam maiúsculas e minúsculas: nomes como segunda-feira, fevereiro e outros não diferenciam maiúsculas de minúsculas.
Espaço em branco. Um ou mais espaços em branco consecutivos na string de formato correspondem a zero ou mais espaços em branco consecutivos na string de data. Além disso, espaços em branco à esquerda e à direita na string de data sempre são permitidos, mesmo que não estejam na string de formato.
Precedência de formato. Quando dois (ou mais) elementos de formato têm informações sobrepostas (por exemplo, %F e %Y afetam o ano), o último geralmente substitui os anteriores.
Essa função é compatível com elementos de formato, mas não tem suporte total para %Q, %a, %A, %g, %G, %j, %u, %U, %V, %w, and %W.. Consulte Elementos de formatos compatíveis com DATETIME para conferir uma lista de elementos de formato aceitos por essa função.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-07-31 UTC."],[],[],null,["PARSE_DATETIME\n==============\n\nConverts text to a date with time.\n\nSample usage\n------------\n\n`PARSE_DATETIME(\"%f\", DateTimeText)`\n\nSyntax\n------\n\n`PARSE_DATETIME( `\u003cvar translate=\"no\"\u003eformat_string\u003c/var\u003e`, `\u003cvar translate=\"no\"\u003etext\u003c/var\u003e` )`\n\n### Parameters\n\n\u003cvar translate=\"no\"\u003eformat_string\u003c/var\u003e - See [Supported Format Elements For DATETIME](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_elements_date_time) for a list of format elements that this function supports.\n\n\u003cvar translate=\"no\"\u003etext\u003c/var\u003e - a text representation of a date.\n\nReturn data type\n----------------\n\nDate \\& Time\n\nExamples\n--------\n\nIn this example, DateTimeText is a field containing a text date and time. The result of applying `PARSE_DATETIME` with the correct *format_string* is a Date \\& Time value.\n\nThe following example parses the *DateTimeText* field containing a date in a natural language format as a Date \\& Time value.\n\nNotes\n-----\n\nWhen using `PARSE_DATETIME`, keep the following in mind:\n\n- **Unspecified fields**. Any unspecified field is initialized from 1970-01-01.\n- **Case insensitive names**. Names, such as Monday, February, and so on, are case insensitive.\n- **Whitespace**. One or more consecutive white spaces in the format string matches zero or more consecutive white spaces in the date string. In addition, leading and trailing white spaces in the date string are always allowed -- even if they are not in the format string.\n- **Format precedence** . When two (or more) format elements have overlapping information (for example both `%F` and `%Y` affect the year), the last one generally overrides any earlier ones.\n\n\u003e This function supports format elements, but does not have full support for `%Q, %a, %A, %g, %G, %j, %u, %U, %V, %w, and %W.` See [Supported Format Elements For DATETIME](https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_elements_date_time) for a list of format elements that this function supports.\n\nRelated resources\n-----------------\n\n- [Calculated fields](/looker/docs/studio/about-calculated-fields)\n- [Looker Studio function list](/looker/docs/studio/function-list)"]]