TALEND - tmap component default Date - talend

I am using a tMap component. I have a date field with default pattern as "dd-MM-yyyy". I just need to insert a Blank Value. i tried '01-01-1900',"",TalendDate.getCurrentDate() : However they gave errors.
Is there a way to could only insert 01-01-1900 or a Null Value with datatype as DATE ?

Try TalendDate.parseDate() function...

you can simply either type null in expression in tmap or use TalendDate.parseDate("yyyy-MM-dd", "1900-01-01")

Related

Set a custom dafault date for a nullable date column on Laravel

I want to set a default date of 1900-01-01 on a nullable date field.
I've tried this
$table->date('fecha_nacimiento')->nullable()
->default(\Carbon\Carbon::make('1900-01-01')->toDateTimeString());
Also
$table->date('fecha_nacimiento')->nullable()
->default(\Carbon\Carbon::make('1900-01-01'));
Also
$table->date('fecha_nacimiento')->nullable()->default('1900-01-01');
When I save from the browser with the HTML date input not set, it saves the date field as null.
The default value on the field only applies when no value, not even null, is assigned.
The blank value is most likely from a blank input from a form. Also, if you are using eloquent mass assignment like so,
$model->fill($request->all());
In this case, your date field is set to null and your insert statement will look like this,
INSERT INTO table_name (fecha_nacimiento, ...)
VALUES (null, ...);

Converting null values in date column to "N/A" in tableau

We have a date column which has a lot of Null Values. We want to replace these null values with "N/A", however for date columns I dont see aliases where I can change it with a click of a button.
So I wrote the following calculation :
IFNULL(str([Arrival Date]),"N/A")
Since this calculation is now a string, I cannot change the format of the date like I could for any normal date column.
Since this new calculated field has string values, I know i cannot convert it back to date. So how can i now handle the date formats ?
BLANK is the default value for NULLin Tableau.
Set how tableau treats these values
Right Click Measure> Format
Select Special Values (bottom most) and
change the value to NA
See this screenshot
In case it's a discrete value refer to Tableau KB: Replacing Null Literals

SQL*Loader - Using sysdate if incoming value is blank

I am trying to create a control file for SQL*Loader script. I have a date column that is defined as NOT NULL. I need to set-up the script to use current date, if the incoming value from the file is blank. I tried a few ways - some examples below - but I keep getting below error when running sql loader, but the format works if I do select from dual
How do I need to set it up in SQLLoader?
PROGRAM_CHANGE_TS POSITION(37:47) DATE "decode(length(trim(:PROGRAM_CHANGE_TS)), 11, to_date(:PROGRAM_CHANGE_TS,'yymmddHH24:MI'),to_date(sysdate,'yymmddHH24:MI'))",
PROGRAM_CHANGE_TS POSITION(37:47) DATE "NVL(Decode(:PROGRAM_CHANGE_TS,'00/00/0000',TO_DATE('01/01/2010','dd/mm/yyyy'),TO_DATE(:PROGRAM_CHANGE_TS,'dd/mm/yyyy')),TO_DATE('01/01/2010','dd/mm/yyyy'))",
oracle decode example ORA-00907: missing right parenthesis
select decode(length(trim(:PROGRAM_CHANGE_TS)), 11, to_date(:PROGRAM_CHANGE_TS,'yymmddHH24:MI'),to_date(sysdate,'yymmddHH24:MI')) from dual
or
select NVL(Decode(:PROGRAM_CHANGE_TS,'00/00/0000',TO_DATE('01/01/2010','dd/mm/yyyy'),TO_DATE(:PROGRAM_CHANGE_TS,'dd/mm/yyyy')),TO_DATE('01/01/2010','dd/mm/yyyy')) from dual
works
What changes do I need to make to use it from a sql loader control file?
You're using to_date in the ctl-file, so remove the explicit DATE specifier.
Also, you don't need to use use decode and length, nvl along with trim is the way to go.
Finally, sysdate is already a date, so you don't need to explicitely convert it into a date with to_date.
The following should work (not tested):
PROGRAM_CHANGE_TS POSITION(37:47) "nvl(to_date(trim(:PROGRAM_CHANGE_TS),'yymmddHH24:MI'),sysdate)",
I need to set-up the script to use current date, if the incoming value from the file is blank.
If you get NULL value for the date column, then simply use NVL function to load SYSDATE instead.
PROGRAM_CHANGE_TS POSITION(37:47) DATE "NVL(:PROGRAM_CHANGE_TS, SYSDATE)"
Don't be confused between BLANK and NULL. 00/00/0000 is neither blank nor null. If you are getting 00/00/0000 as the value, then use DECODE.
PROGRAM_CHANGE_TS POSITION(37:47) DATE "DECODE(:PROGRAM_CHANGE_TS, '00/00/0000', SYSDATE, :PROGRAM_CHANGE_TS)"

Casting date in Talend Data Integration

In a data flow from one table to another, I would like to cast a date.
The date leaves the source table as a string in this format: "2009-01-05 00:00:00:000 + 01:00".
I tried to convert this to a date using a tConvertType, but that is not allowed apparently.
My second option is to cast this string to a date using a formula in a tMap component.
At the moment I tried these formulas:
- TalendDate.formatDate("yyyy-MM-dd",row3.rafw_dz_begi);
- TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",row3.rafw_dz_begi);
- return TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",row3.rafw_dz_begi);
None of these worked. When inserting the result into the target-table (MySQL, InnoDB) a receive the error message that the date is not valid. The format of the target field is a MySQL Date field.
How can I cast the date to the desired format?
Talend offers you a nice way of handling date formats.
You can easily change the date format in the Schema editor tab at the tMap window.
It works for both tMap input and output flows.
I've added a picture for a better illustration.
to cast this string to a date using a formula.... error message that
the date is not valid. The format of the target field is a MySQL Date
field.
What I understand from your question is, you want to insert a date into MySQL Date field.
But the method that you are using, returns the 'String' type.
TalendDate.formatDate(String pattern, Date date); //formats a date into Date/Time string
So in that case, if your field is of 'Date' type.
TalendDate.parseDate("yyyy-MM-dd", TalendDate.formatDate("yyyy-MM-dd",row3.rafw_dz_begi));

IIF IsNothing expression example

I'm using SSRS 2008 and am trying to create an expression where if date field A is greater than date field B or date field A is NULL then this filter will select this record. How do I do this?
I tried this expression to select NULL date fields, but it is not working. I set the datatype to "Text" for now--should I set this to boolean instead? If so, then how can I modify this expression?
=iif(isnothing(Fields!A_date.Value),"yes","no")
=IIF((CDATE(Fields!A_date.Value)>CDate(Fields!B_date.Value)) OR ISNothing(Fields!A_date.Value),"Yes","NO")
Try this !!!