One Star

[resolved] how to insert a 0000-00-00 date in a field using talend?

Hi
I'm trying to insert a "0000-00-00 " in date' field , bu i don't know how?
any ideas?

Mouad
12 REPLIES
Five Stars

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

You need to explain better what you're trying to do.
First issue is that this is not a date.
It may, of course, mean something to wherever you're trying to put it...
One Star

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

Hi,
Apparently he wants to insert a default value in the date field...I want to do the same thing but it does not work ...
I want to insert a default value in my date field because null values are not allowed in that field
is there a way to do that ?
Thanks,
Rajaa
Four Stars

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

Hi,
Do a trick
In the date field subtract two date current date from current date you will get all 0000-00-00. Use expression to check if the input date is null then do above operation.
Thanks
Vaibhav
One Star

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

Hi,
How to make the difference between two dates , and insert a date value (0000-00-00) in a field of date's type?
thank u
Regards
Five Stars

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

you can do it using two way.
1:- TalendDate.compareDate(date1, date2)
the result wheather two date is the same, if first one less than second one return number -1,
equlas return number 0,
bigger than return number 1.
{example} compareDate(2008/11/24 12:15:25, 2008/11/24 16:10:35) return -1 #
2:-TalendDate.diffDate(date1, date2, dateType)
a number of years, months, days ... date1 - date2
{examples} ->>
diffDate(2008/11/24 12:15:25, 2008/10/14 16:10:35, "yyyy") : return 0
->> diffDate(2008/11/24 12:15:25, 2008/10/14 16:10:35, "MM") : return 1
->> diffDate(2008/11/24 12:15:25, 2008/10/14 16:10:35, "dd") : return 41
One Star

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

Hi
thanks for your reply ,
i just want to get the "0000-00-00" (return type is date) at the end to insert it in my field , how can i do that ?
"here is my script but it's not working :
TalendDate.parseDate("dd-MM-yyyy",String.valueOf((TalendDate.diffDate(TalendDate.getCurrentDate(),TalendDate.getCurrentDate()))))

regards
One Star

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

Hi,
You want "0000-00-00" for all the records
or
Instead of Null values you are going to insert "0000-00-00"
Thanks,
kumar
One Star

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

i want to do the second choice :
Instead of Null values you are going to insert "0000-00-00"
thanks
Regards Smiley Happy
Five Stars

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

try this, but i don`t think so any database allows to insert such value if any please do post here for reference.

TalendDate.parseDate("yyyy-MM-dd","0000.00.00");
One Star

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

it didn't work,
i get this value instead : 0002-11-30 BC (i'm using postgres database )
One Star

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

Hi,
I think any database doesn't allow "0000-00-00".
Insert "0001-01-01" instead of "0000-00-00" in date filed.
Thanks,
kumar
One Star

Re: [resolved] how to insert a 0000-00-00 date in a field using talend?

thank brother for your reply,
it did worked Smiley Happy
thank u again
i'll set this topic as solved
Regards