The below google bigquery provide us idea to convert timestamp to different date and time values:
SELECT CURRENT_DATE() as currentdate
, CURRENT_TIME() currenttime, CURRENT_timestamp() currentdatetime
, DATE(TIMESTAMP(CURRENT_timestamp())) AS dateonly
, MONTH(TIMESTAMP(CURRENT_timestamp())) as monthonly
, YEAR(TIMESTAMP(CURRENT_timestamp())) as yearonly
, HOUR(TIMESTAMP(CURRENT_timestamp())) as houronly
, MINUTE(TIMESTAMP(CURRENT_timestamp())) as minuteonly
, SECOND(TIMESTAMP(CURRENT_timestamp())) as secondonly
, DAY(TIMESTAMP(CURRENT_timestamp())) as dayonly
, PARSE_UTC_USEC(STRING(CURRENT_timestamp())) as timestamtounix
, NOW() AS CurrentUnixTimestamp
, USEC_TO_TIMESTAMP(1465814687003321) AS unixtotimestamp
FROM [project:dataset.table] LIMIT 1;
SELECT CURRENT_DATE() as currentdate
, CURRENT_TIME() currenttime, CURRENT_timestamp() currentdatetime
, DATE(TIMESTAMP(CURRENT_timestamp())) AS dateonly
, MONTH(TIMESTAMP(CURRENT_timestamp())) as monthonly
, YEAR(TIMESTAMP(CURRENT_timestamp())) as yearonly
, HOUR(TIMESTAMP(CURRENT_timestamp())) as houronly
, MINUTE(TIMESTAMP(CURRENT_timestamp())) as minuteonly
, SECOND(TIMESTAMP(CURRENT_timestamp())) as secondonly
, DAY(TIMESTAMP(CURRENT_timestamp())) as dayonly
, PARSE_UTC_USEC(STRING(CURRENT_timestamp())) as timestamtounix
, NOW() AS CurrentUnixTimestamp
, USEC_TO_TIMESTAMP(1465814687003321) AS unixtotimestamp
FROM [project:dataset.table] LIMIT 1;
No comments:
Post a Comment