General Questions

Expand all | Collapse all

How to insert date values in yyyy format

Jump to Best Answer
  • 1.  How to insert date values in yyyy format

     
    Posted 06-29-2019 06:48 AM
    Greetings. If I want to insert date values in an GCE table, the column datatype is given as "date" and values are given in the GCE supported format "yyyy-MM-dd".

    But how can the date values be inserted in an "yyyy" format in a GCE table? Is there any possibility to insert values in this format?


  • 2.  RE: How to insert date values in yyyy format
    Best Answer

    Posted 07-01-2019 02:03 AM
    Hello!

    I think you can use built-in functions for that, as shown:

    0: jdbc:ignite:thin://localhost> create table years (id int primary key, year date);
    No rows affected (0,047 seconds)
    0: jdbc:ignite:thin://localhost> insert into years(id, year) values (2017, parsedatetime('2017', 'yyyy', 'en'));
    1 row affected (0,007 seconds)
    0: jdbc:ignite:thin://localhost> select id, formatdatetime(year, 'yyyy', 'en') as year from years;
    +--------------------------------+--------------------------------+
    |               ID               |              YEAR              |
    +--------------------------------+--------------------------------+
    | 2017                           | 2017                           |
    +--------------------------------+--------------------------------+
    1 row selected (0,004 seconds)

    Regards,

    ------------------------------
    Ilya Kasnacheev
    Community Support Specialist
    GridGain
    ------------------------------



Would you attend a July Meetup?


Announcements