Trying to convert epoch code field (string type) to timestamp
up vote
2
down vote
favorite
Trying to convert from epoch code to timestamp, in legacy SQL it's working fine and in standard SQL I'm getting an error.
Field name custom_field_6 (string type field) represent epoch time and I want to convert it to timestamp (in standard SQL)
In legacy SQL I did the following:
select
custom_field_6 as custom_field_6,
timestamp(custom_field_6) as custom_field_6_convert
FROM [yellowhead-visionbi-rivery:yellowhead_prod.affise_conversions]
The query output
In standard sql:
select
yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions``
custom_field_6 as custom_field_6,
cast(custom_field_6 as date) as custom_field_6_converted
FROM
The error I get: "invalid date"
google-bigquery
add a comment |
up vote
2
down vote
favorite
Trying to convert from epoch code to timestamp, in legacy SQL it's working fine and in standard SQL I'm getting an error.
Field name custom_field_6 (string type field) represent epoch time and I want to convert it to timestamp (in standard SQL)
In legacy SQL I did the following:
select
custom_field_6 as custom_field_6,
timestamp(custom_field_6) as custom_field_6_convert
FROM [yellowhead-visionbi-rivery:yellowhead_prod.affise_conversions]
The query output
In standard sql:
select
yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions``
custom_field_6 as custom_field_6,
cast(custom_field_6 as date) as custom_field_6_converted
FROM
The error I get: "invalid date"
google-bigquery
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Trying to convert from epoch code to timestamp, in legacy SQL it's working fine and in standard SQL I'm getting an error.
Field name custom_field_6 (string type field) represent epoch time and I want to convert it to timestamp (in standard SQL)
In legacy SQL I did the following:
select
custom_field_6 as custom_field_6,
timestamp(custom_field_6) as custom_field_6_convert
FROM [yellowhead-visionbi-rivery:yellowhead_prod.affise_conversions]
The query output
In standard sql:
select
yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions``
custom_field_6 as custom_field_6,
cast(custom_field_6 as date) as custom_field_6_converted
FROM
The error I get: "invalid date"
google-bigquery
Trying to convert from epoch code to timestamp, in legacy SQL it's working fine and in standard SQL I'm getting an error.
Field name custom_field_6 (string type field) represent epoch time and I want to convert it to timestamp (in standard SQL)
In legacy SQL I did the following:
select
custom_field_6 as custom_field_6,
timestamp(custom_field_6) as custom_field_6_convert
FROM [yellowhead-visionbi-rivery:yellowhead_prod.affise_conversions]
The query output
In standard sql:
select
yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions``
custom_field_6 as custom_field_6,
cast(custom_field_6 as date) as custom_field_6_converted
FROM
The error I get: "invalid date"
google-bigquery
google-bigquery
edited Nov 21 at 20:03
Felipe Hoffa
20.5k249104
20.5k249104
asked Nov 21 at 15:39
ornachshon
133
133
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Below id for BigQuery Standard SQL
#standardSQL
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions`
you can test it using dummy data as below
#standardSQL
WITH `project.dataset.table` AS (
SELECT '1540051185' custom_field_6 UNION ALL
SELECT '1540252572'
)
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `project.dataset.table`
with result
Row custom_field_6 custom_field_6_convert
1 1540051185 2018-10-20 15:59:45 UTC
2 1540252572 2018-10-22 23:56:12 UTC
This is the error I get: Query Failed Error: Bad int64 value: {installed_at} Job ID: yellowhead-visionbi-rivery:US.bquijob_70505117_1673a6cfa50
– ornachshon
Nov 22 at 7:58
Provide example of your data
– Mikhail Berlyant
Nov 22 at 8:05
Hi. It's working. Thank you.
– ornachshon
Nov 22 at 8:40
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Below id for BigQuery Standard SQL
#standardSQL
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions`
you can test it using dummy data as below
#standardSQL
WITH `project.dataset.table` AS (
SELECT '1540051185' custom_field_6 UNION ALL
SELECT '1540252572'
)
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `project.dataset.table`
with result
Row custom_field_6 custom_field_6_convert
1 1540051185 2018-10-20 15:59:45 UTC
2 1540252572 2018-10-22 23:56:12 UTC
This is the error I get: Query Failed Error: Bad int64 value: {installed_at} Job ID: yellowhead-visionbi-rivery:US.bquijob_70505117_1673a6cfa50
– ornachshon
Nov 22 at 7:58
Provide example of your data
– Mikhail Berlyant
Nov 22 at 8:05
Hi. It's working. Thank you.
– ornachshon
Nov 22 at 8:40
add a comment |
up vote
1
down vote
accepted
Below id for BigQuery Standard SQL
#standardSQL
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions`
you can test it using dummy data as below
#standardSQL
WITH `project.dataset.table` AS (
SELECT '1540051185' custom_field_6 UNION ALL
SELECT '1540252572'
)
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `project.dataset.table`
with result
Row custom_field_6 custom_field_6_convert
1 1540051185 2018-10-20 15:59:45 UTC
2 1540252572 2018-10-22 23:56:12 UTC
This is the error I get: Query Failed Error: Bad int64 value: {installed_at} Job ID: yellowhead-visionbi-rivery:US.bquijob_70505117_1673a6cfa50
– ornachshon
Nov 22 at 7:58
Provide example of your data
– Mikhail Berlyant
Nov 22 at 8:05
Hi. It's working. Thank you.
– ornachshon
Nov 22 at 8:40
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Below id for BigQuery Standard SQL
#standardSQL
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions`
you can test it using dummy data as below
#standardSQL
WITH `project.dataset.table` AS (
SELECT '1540051185' custom_field_6 UNION ALL
SELECT '1540252572'
)
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `project.dataset.table`
with result
Row custom_field_6 custom_field_6_convert
1 1540051185 2018-10-20 15:59:45 UTC
2 1540252572 2018-10-22 23:56:12 UTC
Below id for BigQuery Standard SQL
#standardSQL
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `yellowhead-visionbi-rivery.yellowhead_prod.affise_conversions`
you can test it using dummy data as below
#standardSQL
WITH `project.dataset.table` AS (
SELECT '1540051185' custom_field_6 UNION ALL
SELECT '1540252572'
)
SELECT
custom_field_6,
TIMESTAMP_SECONDS(CAST(custom_field_6 AS INT64)) custom_field_6_convert
FROM `project.dataset.table`
with result
Row custom_field_6 custom_field_6_convert
1 1540051185 2018-10-20 15:59:45 UTC
2 1540252572 2018-10-22 23:56:12 UTC
answered Nov 21 at 16:03
Mikhail Berlyant
54.5k43368
54.5k43368
This is the error I get: Query Failed Error: Bad int64 value: {installed_at} Job ID: yellowhead-visionbi-rivery:US.bquijob_70505117_1673a6cfa50
– ornachshon
Nov 22 at 7:58
Provide example of your data
– Mikhail Berlyant
Nov 22 at 8:05
Hi. It's working. Thank you.
– ornachshon
Nov 22 at 8:40
add a comment |
This is the error I get: Query Failed Error: Bad int64 value: {installed_at} Job ID: yellowhead-visionbi-rivery:US.bquijob_70505117_1673a6cfa50
– ornachshon
Nov 22 at 7:58
Provide example of your data
– Mikhail Berlyant
Nov 22 at 8:05
Hi. It's working. Thank you.
– ornachshon
Nov 22 at 8:40
This is the error I get: Query Failed Error: Bad int64 value: {installed_at} Job ID: yellowhead-visionbi-rivery:US.bquijob_70505117_1673a6cfa50
– ornachshon
Nov 22 at 7:58
This is the error I get: Query Failed Error: Bad int64 value: {installed_at} Job ID: yellowhead-visionbi-rivery:US.bquijob_70505117_1673a6cfa50
– ornachshon
Nov 22 at 7:58
Provide example of your data
– Mikhail Berlyant
Nov 22 at 8:05
Provide example of your data
– Mikhail Berlyant
Nov 22 at 8:05
Hi. It's working. Thank you.
– ornachshon
Nov 22 at 8:40
Hi. It's working. Thank you.
– ornachshon
Nov 22 at 8:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415587%2ftrying-to-convert-epoch-code-field-string-type-to-timestamp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown