Datetime data types

Snowflake में Data Types और Functions

Jake Roach

Field Data Engineer

DATE data types

  • Date वैल्यूज उस दिनांक को स्टोर करती हैं जब कुछ हुआ था
                            2023-04-01
                            YYYY-MM-DD
  CREATE TABLE sales (
      transaction_date DATE  -- Define a column of type `DATE`
  );
Snowflake में Data Types और Functions

DATE data types

SELECT

TO_DATE('2023-04-01') AS the_date, -- Convert a string into a DATE
'2023-04-01'::DATE AS casted_date -- Casted using <value>::DATE
;
                         the_date  | casted_date  
                       ----------- | ------------  
                        2023-04-01 | 2023-04-01
Snowflake में Data Types और Functions

Time data types

  • उस समय के घंटे, मिनट, और सेकंड को कैप्चर करता है जब इवेंट हुआ
                               08:24:08
                               HH:MM:SS
CREATE TABLE sales (
    transaction_time TIME  -- Create a column with the `TIME` keyword
);
  • TIME कॉलम परिभाषित करें
Snowflake में Data Types और Functions

Time data types

SELECT

TO_TIME('08:24:04') AS the_time,
'08:24:04'::TIME AS casted_time
;
                     |  the_time  | casted_time |
                     | ---------- | ----------- |
                     |  08:24:08  |  08:24:08   |
  • TO_TIME फंक्शन
  • :: से cast करें
Snowflake में Data Types और Functions

Timestamp data types

  • TIMESTAMP एक साथ date और time कैप्चर करता है
                        2023-04-01 08:24:04
                        YYYY-MM-DD HH:MM:SS
CREATE TABLE (
    transaction_timestamp TIMESTAMP
);
Snowflake में Data Types और Functions

Timestamp data types

SELECT 
    TO_TIMESTAMP('2023-04-01 08:24:04') AS the_timestamp,
    '2023-04-01 08:24:04'::TIMESTAMP AS casted_timestamp          
;
  • स्ट्रिंग को timestamp में बदलें: TO_TIMESTAMP या <value>::TIMESTAMP
  • datetime डेटा स्टोर करने का सबसे आम तरीका
                  the_timestamp     |    casted_timestamp     
              --------------------- | ----------------------  
               2024-04-01 08:24:08  |  2024-04-01 08:24:08    
Snowflake में Data Types और Functions

Examples

SELECT
    TO_DATE('2021-05-14') AS the_date,
    TO_TIME('06:13:00') AS the_time,
    TO_TIMESTAMP('2021-05-14T06:13:00') AS the_timestamp,


-- Extract the DATE from a TIMESTAMP, we could do the same with TIME! transaction_timestamp::DATE AS casted_date
;
           the_date   |   the_time  |     the_timestamp    | casted_date  
         ------------ | ----------- | -------------------- | ------------  
          2021-05-14  |   06:13:00  | 2021-05-14T06:13:00  |  2021-05-14
Snowflake में Data Types और Functions

Timezones

डिफॉल्ट रूप से, DATE, TIME, और TIMESTAMP बिना timezone के स्टोर होते हैं

$$

TIMESTAMP_NTZ

  • TIMESTAMP का डिफॉल्ट इम्प्लिमेंटेशन
  • कोई timezone स्टोर नहीं होता

$$

TIMESTAMP_LTZ

  • लोकल timezone पर निर्भर

$$

TIMESTAMP_TZ

  • यूजर timezone को specify करता है
1 https://docs.snowflake.com/en/sql-reference/data-types-datetime#timestamp-ltz-timestamp-ntz-timestamp-tz
Snowflake में Data Types और Functions

अभ्यास करते हैं!

Snowflake में Data Types और Functions

Preparing Video For Download...