#1 2009-05-07 12:06:12

Kiva
New member
Registered: 2009-04-20
Posts: 7

Select NOW() problem

Tags: [date, mysql, now()]

Hi guy,

I have a problem with a job. I need to know the yesterday date to find a file for my job.
I would like use functions date of mysql like DATE_SUB but it doesn't work.

I use a tMysqlInput or a tMysqlRow but I have an error when I use the function NOW(). Indeed, talend use NOW() as a variable name and it doesn't work (logical)

How can I use these functions to create variable(s?) and use them in a tJava?

I post two screen shot for a better explaination.

Thanks for your help.


Uploaded Images

Offline

#2 2009-05-08 20:40:54

tnewman
Member
Company: Lunexa
Registered: 2008-11-15
Posts: 194
Website

Re: Select NOW() problem

Hi,

The syntax for the NOW() stmt is :-

SELECT NOW() FROM table_name

I guess you could use any table in your db.

As for assigning to context variable, try TjavaRow like :-

if (row1.datetime !=null) {
    context.var_name=row1.datetime;
}

HTH


------------------
Talend Version - TIS 4.1.2
Generated Code - Java
OS - WinXP SP3 / Linux

Offline

#3 2009-05-08 23:10:04

bluesin
Member
Registered: 2008-01-30
Posts: 44

Re: Select NOW() problem

You use the table name of dual when you want to select on literals or functions without accessing an actual table. "dual" is a dummy table operand, not sure how it'll work in Talend though...

Select now() from dual;

Offline

#4 2009-05-11 05:31:06

shong
Talend team
Registered: 2007-08-29
Posts: 10310
Website

Re: Select NOW() problem

Hello
As tnewman and bluesin said.
"select now() from dual"
Please see my screenshot.

Best regards

        shong


Uploaded Images


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#5 2009-05-11 09:50:58

Kiva
New member
Registered: 2009-04-20
Posts: 7

Re: Select NOW() problem

Hi guy,

Thanks for your answer.

To find the date, I used a tJava with Calendar.add method and this solution works.

Offline

Board footer

Powered by FluxBB