You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Harikrishnan A <ha...@yahoo.com> on 2015/12/20 17:18:27 UTC

Timestamp Query

Hello,
How do I set a timestamp value with specific timezone in cassandra. I understand that it captures the timezone of the co ordinator node while inserting. What about if I want to insert and display the timezone that I preferred nstead of the default co ordinator timezone. 
Thanks & Regards,Hari

Re: Timestamp Query

Posted by Eric Stevens <mi...@gmail.com>.
Generally speaking (both for Cassandra as well as for many other projects),
timestamps don't carry a timezone directly.  A single point in time has a
consistent value for timestamp regardless of the timezone, and when you
convert a timestamp to a human-friendly value, you can attach a timezone to
see what the local time in that timezone was as of that timestamp.

Cassandra, like many projects, uses timestamps counted as number of
predefined intervals since 1970-01-01T00:00:00Z (the Unix Epoch).  This is
timestamp 0.

In Cassandra, timestamp fields use millisecond precision (milliseconds
since timestamp 0), while writetime() (or USING TIMESTAMP) uses
microseconds since timestamp 0.

cqlsh prefers the system timezone when displaying timestamps in friendly
format. If you want to display timestamps in a different timezone, you can
set the TZ environment variable to accomplish this (see
http://stackoverflow.com/questions/26595649/specify-cqlsh-output-timezone).


If you need to track a timezone with your timestamp (i.e. it's not good
enough to know the moment in time, but you also need to know the local
offset that the timestamp was written under), you'll need to track that in
a separate field, since Cassandra does not provide a TimestampWithTimezone
data type.

On Sun, Dec 20, 2015 at 11:09 AM Jai Bheemsen Rao Dhanwada <
jaibheemsen@gmail.com> wrote:

> https://datastax.github.io/java-driver/features/query_timestamps/
>
> On Sun, Dec 20, 2015 at 9:48 PM, Harikrishnan A <ha...@yahoo.com> wrote:
>
>> Hello,
>>
>> How do I set a timestamp value with specific timezone in cassandra. I
>> understand that it captures the timezone of the co ordinator node while
>> inserting.
>> What about if I want to insert and display the timezone that I preferred
>> nstead of the default co ordinator timezone.
>>
>> Thanks & Regards,
>> Hari
>>
>
>

Re: Timestamp Query

Posted by Jai Bheemsen Rao Dhanwada <ja...@gmail.com>.
https://datastax.github.io/java-driver/features/query_timestamps/

On Sun, Dec 20, 2015 at 9:48 PM, Harikrishnan A <ha...@yahoo.com> wrote:

> Hello,
>
> How do I set a timestamp value with specific timezone in cassandra. I
> understand that it captures the timezone of the co ordinator node while
> inserting.
> What about if I want to insert and display the timezone that I preferred
> nstead of the default co ordinator timezone.
>
> Thanks & Regards,
> Hari
>