How to cast utc date to GMT +8 in Presto SQL? - presto

Would like to check how to convert utc time to GMT +8 timezone in Presto sql?
http://teradata.github.io/presto/docs/127t/functions/datetime.html suggests using current_timezone but I am not sure how.

Related

how to Covert all the timestamps to EST in Hive table

I have a Hive table which contains a timestamp field and it can have any timezone ..(UTC/PST/CST....)
I want to convert all of them to a single timestamp, EST. it can be done either in Hive or Pyspark.
Basically, i am using it in my pyspark application which has a grouping logic on this datetime field and before doing that we want to have all the times in Hive table to be converted to EST time.
Sid
Mention to the facts which HIV Timezone have limitation on maximum time associates to Y2K38 bugs and JDBC compatibility issue,
TIMESTAMP type to serde2 that supports unix timestamp (1970-01-01 00:00:01 UTC to 2038-01-19 03:14:07 UTC) with optional nanosecond precision using both LazyBinary and LazySimple SerDes.
For LazySimpleSerDe, the data is stored in jdbc compliant java.sql.Timestamp parsable strings.
HIV-2272
Here is simulation associates to supporting timestamps earlier than 1970 and later than 2038.
Hive JDBC doesn't support TIMESTAMP column
Therefore, I think will be better if you are using HIV DataType of Date Type or String Type. Then you can use any timezone offset as the default on persistent.
* utc_timestamp is the column name */
/* bellow will convert a timestamp in UTC to EST timezone */
select from_utc_timestamp(utc_timestamp, 'EST') from table1;
Hope this helps.
HIV Data Types
Sidd, usually Hive uses the local timezone of the host where the data was written. The function from_utc_timestamp() and to_utc_timestamp can we very helpful. Instead of stating the timezone as UTC/EST you should rather use location/region in that case, since this will account for the day light savings.
Here's a helpful link for more examples: Local Time Convert To UTC Time In Hive
In case you have further questions, please share what have you already tried and share a sample snippet of your data for investigating further.

Get UTC offset and DST information for a specific timezone in node? [duplicate]

This question already has answers here:
Calculate the UTC offset given a TimeZone string in JavaScript
(5 answers)
Closed 4 years ago.
I need to get UTC offset and DST information for a specific timezone in node.js.
In case i use an external web service, it is necessary that the service used is free with unlimited requests if it's possible.
Example: if i put Europe/Rome timezone as a parameter i need to have 3600 as utc offset and 0 as DST information.
I found timezonedb but there is a rate limit where you can only send request to the server once per second.
For anything time related you should look into using moment.js
Here is the documentation for moment.js
Here is the documentation for moment.js timezone
Below is taken from the moment.js timezone docs
var jun = moment("2014-06-01T12:00:00Z");
var dec = moment("2014-12-01T12:00:00Z");
jun.tz('America/Los_Angeles').format('ha z'); // 5am PDT
dec.tz('America/Los_Angeles').format('ha z'); // 4am PST
jun.tz('America/New_York').format('ha z'); // 8am EDT
dec.tz('America/New_York').format('ha z'); // 7am EST
You should be able to find the correct methods based on your use case.

lose 4 hours in conversion from UTC

I have a script that requests a datapull from a sql server.
For the request I send string like:
start_of_pull="2018-09-13 11:00:00"
The sql script pulls the data using UTC timestamp.
It returns a UTC timestamp of
1536850800.
But when I use pandas' pandas.to_datetime(df['TIME'],unit='s')
it returns at timestamp of
2018-09-13 15:00:00
Any ideas why I'm losing 4 hours?
My solution to the problem is to subtract 14,400 seconds

Azure minute/hourly metric collection issue using SDK

hi i'm trying to get the hourly/minute metrics using the sdk provided by azure but i'm confused ,i got the below result isn't Partition key the Time?
PartitionKey=20170605T1531 RowKey=system;All TimeStamp=Mon Jun 05 21:02:24 IST 2017
PartitionKey=20170605T1533 RowKey=system;All TimeStamp=Mon Jun 05 21:04:23 IST 2017
PartitionKey=20170605T1539 RowKey=system;All TimeStamp=Mon Jun 05 21:10:24 IST 2017
PartitionKey=20170605T1540 RowKey=system;All TimeStamp=Mon Jun 05 21:11:24 IST 2017
Please explain the concept /difference in PartitionKey and TimeStamp?
Please explain the concept /difference in PartitionKey and TimeStamp?
In Azure Table service, each entity has 3 system properties that specify a partition key, a row key, and a timestamp column that the Table service uses to track when the entity was last updated (this happens automatically and you cannot manually overwrite the timestamp with an arbitrary value).

Node.js and MongoDB Time Zone Issue UTC not being converted correctly by driver?

I have a strange thing occurring and I hope someone can point out what i am missing.
In MongoDB I have a field DT that is of Type Date
An example of what the date looks like in MongoDB is 2014-10-01 10:28:04.329-04:00
When I query MongoDB from Node.js using MongoClient, Node.js is returning this:
2014-10-01T14:28:04.329Z
As i understand it the driver is suppose to convert UTC to local time. In my case it should be Eastern Time (EDT). Why would Node be adding 4 hours instead?
I am loading the date into MongoDB from Java using the Java driver. The variable is set using
new Date();
Node isn't adding 4 hours. Both show exactly the same instant.
2014-10-01 10:28:04.329-04:00
is exactly the same as
2014-10-01T14:28:04.329Z
only one is in a EDT timezone which has -04:00 offset to UTC (so it's four hours earlier there), and the other is in UTC.
Probably you have your server configured in EDT and your client is set to UTC or the other way around.
Unless you need the exact same strings, I wouldn't worry about it.
Or, even better, set both the client and server machine to the same timezone, preferably UTC.

Resources