how do i convert unix time stamp to formatted date while using json_extract_scalar in bigquery

Ipkiss

for example i have this

SELECT  
JSON_EXTRACT_SCALAR(jsonBlob, '$.userName') as userName,
JSON_EXTRACT_SCALAR(jsonBlob, '$.Id') as id,
JSON_EXTRACT_SCALAR(jsonBlob, '$.CreatedDateTime') as CreatedDateTime,
from dataset.tableName

this gives me back the a result but the CreatedDateTime field is in unix time stamp, i want to get it in 2018-02-01 17:11:43 format. i know i can use

SELECT MSEC_TO_TIMESTAMP(CreatedDateTime) as CreatedDateTime 

to convert it later, but what if i want to do this in the above select statement. any idea?

Mikhail Berlyant
SELECT 
  MSEC_TO_TIMESTAMP(INTEGER(JSON_EXTRACT_SCALAR(jsonBlob, '$.CreatedDateTime'))) as CreatedDateTime   

above is for Legacy SQL as looks like it is what you use in your question

forgot to mention - for BigQuery Standard SQL , the same will look like below

SELECT 
  TIMESTAMP_MILLIS(CAST(JSON_EXTRACT_SCALAR(jsonBlob, '$.CreatedDateTime') AS INT64)) as CreatedDateTime   

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How do I tell the `date` command to only show the time?

分類Dev

How do I create an HTML-formatted ICS message body using ical.net?

分類Dev

How do I convert city names to time zones?

分類Dev

Incorrect results using Pyspark-sql to convert unix time to datetime

分類Dev

How do I convert a string with no delimiters into a date?

分類Dev

How do I convert a Firestore date/Timestamp to Date in Kotlin?

分類Dev

bigqueryでjson_extract_scalarを使用しているときに、UNIXタイムスタンプをフォーマットされた日付に変換するにはどうすればよいですか?

分類Dev

how do i convert format of current time in python

分類Dev

How to get a formatted date and time string from `now`?

分類Dev

How do i convert List into datetime.date object?

分類Dev

How do I convert a String of date time data to a LocalDate?

分類Dev

How can I convert time into percent using moment

分類Dev

Convert Oracle DATE to Unix-style time (seconds since 1906?)

分類Dev

How do I convert date formats using a regex in R?

分類Dev

Unix Time stamp creation in C from custom data fields

分類Dev

How to convert this STRING into time + date

分類Dev

How do I get the current date and time in the format given Below

分類Dev

why Unix Time Stamp for same time is different in different timezone

分類Dev

How do I convert an object containing an Oracle Date to a DateTime?

分類Dev

Convert range formatted as date to text

分類Dev

how do i convert int to date in specific form?

分類Dev

How do I convert API supplied date/time string into readable format?

分類Dev

Using the Jackson streaming api for JSON, how do I while loop through an object?

分類Dev

Convert date using joda time and ignore time

分類Dev

How to work with a Javascript +Date() numeric time stamp in Python?

分類Dev

How do I convert number to words while looping in LESS?

分類Dev

How to log Serial data with time stamp?

分類Dev

How to convert time date from JSON to human readable?

分類Dev

How to stamp prompt at command execute time?

Related 関連記事

  1. 1

    How do I tell the `date` command to only show the time?

  2. 2

    How do I create an HTML-formatted ICS message body using ical.net?

  3. 3

    How do I convert city names to time zones?

  4. 4

    Incorrect results using Pyspark-sql to convert unix time to datetime

  5. 5

    How do I convert a string with no delimiters into a date?

  6. 6

    How do I convert a Firestore date/Timestamp to Date in Kotlin?

  7. 7

    bigqueryでjson_extract_scalarを使用しているときに、UNIXタイムスタンプをフォーマットされた日付に変換するにはどうすればよいですか?

  8. 8

    how do i convert format of current time in python

  9. 9

    How to get a formatted date and time string from `now`?

  10. 10

    How do i convert List into datetime.date object?

  11. 11

    How do I convert a String of date time data to a LocalDate?

  12. 12

    How can I convert time into percent using moment

  13. 13

    Convert Oracle DATE to Unix-style time (seconds since 1906?)

  14. 14

    How do I convert date formats using a regex in R?

  15. 15

    Unix Time stamp creation in C from custom data fields

  16. 16

    How to convert this STRING into time + date

  17. 17

    How do I get the current date and time in the format given Below

  18. 18

    why Unix Time Stamp for same time is different in different timezone

  19. 19

    How do I convert an object containing an Oracle Date to a DateTime?

  20. 20

    Convert range formatted as date to text

  21. 21

    how do i convert int to date in specific form?

  22. 22

    How do I convert API supplied date/time string into readable format?

  23. 23

    Using the Jackson streaming api for JSON, how do I while loop through an object?

  24. 24

    Convert date using joda time and ignore time

  25. 25

    How to work with a Javascript +Date() numeric time stamp in Python?

  26. 26

    How do I convert number to words while looping in LESS?

  27. 27

    How to log Serial data with time stamp?

  28. 28

    How to convert time date from JSON to human readable?

  29. 29

    How to stamp prompt at command execute time?

ホットタグ

アーカイブ