Getting "Null" values on inserting into table for "date/timestamp" datatypes column

hive

#1

Hi,

I’ve created a table having two columns with “timestamp” datatype.But on inserting data into that column, its getting as “Null” values. Even I’ve tried with “date” datatype too but still getting “Null”. Also can you please update when you to use “timestamp” and “date” or can be used anyone datatype?

Here is the code:
create table duplicateRemoval(col1 string,col2 string,createdate timestamp, dayid timestamp,marketid int) row format delimited fields terminated by ‘,’;

insert into duplicateRemoval(col1,col2,createdate,dayid,marketid)values(“A”,“1”,“20180810”,“20130801”,1234);

select * from duplicateRemoval;
op:



Practice hive on state of the art Big Data cluster - https://labs.itversity.com



#2

@saikiranchepuri35,

Use the below command.

insert into duplicateRemoval(col1,col2,createdate,dayid,marketid)values("A","1",'2018-08-10','2013-08-01',1234);


#3

Hey @Sravan_Kumar thanks for quick response. Now it’s perfect it is inserted the values rather than “Null”.
Can you please update on diff b/w “date” and “timestamp” datatype and when to use it in which scenario?


#4

@saikiranchepuri35,

When timestamp datatype is used, it will results in YYYY-MM-DD HH:MM:SS, where date datatype is used , it will results in YYYY-MM-DD