SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using Date Logic
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jedi_knight
Starting Member

USA
6 Posts

Posted - 05/29/2012 :  18:06:40  Show Profile  Reply with Quote
I'm trying include date logic that follows this idea: NXT_PMT_DUE_DAT <= today's date. In SAS, you can use TODAY() in that line of code.
Does SQL have an equivalent date function that I can implement? When I use CURDATE(), I get the following error in the message log:

OLE DB provider "MSDASQL" for linked server "ACLS_PROD" returned message "[IBM][CLI Driver][DB2] SQL0206N "CURDATE" is not valid in the context where it is used. SQLSTATE=42703
".
Msg 7350, Level 16, State 2, Line 19
Cannot get the column information from OLE DB provider "MSDASQL" for linked server "ACLS_PROD".

Any idea how I can resolve this?

robvolk
Most Valuable Yak

USA
15557 Posts

Posted - 05/29/2012 :  18:23:43  Show Profile  Visit robvolk's Homepage  Reply with Quote
You can use GETDATE() or CURRENT_TIMESTAMP.
Go to Top of Page

jedi_knight
Starting Member

USA
6 Posts

Posted - 05/29/2012 :  18:26:03  Show Profile  Reply with Quote
Thanks for the advice but I'm not sure how to use it. Here's what the code looks like:

SELECT *
FROM OPENQUERY(ACLS_PROD, 'SELECT A182.BK_NUM as Bank,
A182.LN_NUM as Loan_Number,
A182.ACT_STA as Ln_Sta,
A182.NXT_PMT_DUE_DAT as Due_Date,
A182.CUR_LN_BAL as Balance,
A182.INS_REF_NUM as Debt_Can_Ref

FROM PZFRL.ALT0182 A182

WHERE A182.ACT_STA IN(''0'', ''1'', ''2'')
AND (A182.INS_REF_NUM IN(''SDC'', ''SDD'', ''SDU'', ''SLF'', ''SUF'', ''DSF'',
''JDC'', ''JDD'', ''JDU'', ''JLF'', ''JDF'')
AND A182.NXT_PMT_DUE_DAT <= GETDATE())

ORDER BY A182.BK_NUM,
A182.LN_NUM

')


Do you know why it's jacked up?



quote:
Originally posted by robvolk

You can use GETDATE() or CURRENT_TIMESTAMP.

Go to Top of Page

robvolk
Most Valuable Yak

USA
15557 Posts

Posted - 05/29/2012 :  18:42:26  Show Profile  Visit robvolk's Homepage  Reply with Quote
Well, what does "jacked up" mean? Do you get an error? No data? Wrong data? Is ACLS_PROD a SQL Server, or another RDBMS product?
Go to Top of Page

jedi_knight
Starting Member

USA
6 Posts

Posted - 05/29/2012 :  18:50:21  Show Profile  Reply with Quote
Sorry. I guess I should've been more specific. Here's a copy of the error in the message log:

OLE DB provider "MSDASQL" for linked server "ACLS_PROD" returned message "[IBM][CLI Driver][DB2] SQL0440N No authorized routine named "GETDATE" of type "" having compatible arguments was found. SQLSTATE=42884
".
Msg 7350, Level 16, State 2, Line 19
Cannot get the column information from OLE DB provider "MSDASQL" for linked server "ACLS_PROD".



quote:
Originally posted by robvolk

Well, what does "jacked up" mean? Do you get an error? No data? Wrong data? Is ACLS_PROD a SQL Server, or another RDBMS product?

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
29138 Posts

Posted - 05/29/2012 :  18:59:40  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Try CURRENT_TIMESTAMP instead as that is the standard function name.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

jedi_knight
Starting Member

USA
6 Posts

Posted - 05/29/2012 :  22:18:25  Show Profile  Reply with Quote
That didn't work either.

Hmmm, anyone else have a suggestion?


quote:
Originally posted by SwePeso

Try CURRENT_TIMESTAMP instead as that is the standard function name.


N 56°04'39.26"
E 12°55'05.63"


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 05/29/2012 :  22:21:54  Show Profile  Reply with Quote
quote:
Originally posted by jedi_knight

That didn't work either.

Hmmm, anyone else have a suggestion?


quote:
Originally posted by SwePeso

Try CURRENT_TIMESTAMP instead as that is the standard function name.


N 56°04'39.26"
E 12°55'05.63"




what do you mean by it didnt work? did you get some error?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16745 Posts

Posted - 05/29/2012 :  22:33:59  Show Profile  Reply with Quote
try

CURRENT DATE


KH
Time is always against us

Go to Top of Page

jedi_knight
Starting Member

USA
6 Posts

Posted - 05/29/2012 :  23:00:07  Show Profile  Reply with Quote
Yes. Same error.



quote:
Originally posted by visakh16

quote:
Originally posted by jedi_knight

That didn't work either.

Hmmm, anyone else have a suggestion?


quote:
Originally posted by SwePeso

Try CURRENT_TIMESTAMP instead as that is the standard function name.


N 56°04'39.26"
E 12°55'05.63"




what do you mean by it didnt work? did you get some error?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16745 Posts

Posted - 05/29/2012 :  23:30:43  Show Profile  Reply with Quote
Maybe you should post your query in a DB2 forums like http://www.dbforums.com/db2/ as the error is not related to SQL Server but DB2. And there aren't many DB2 expert around here.


KH
Time is always against us

Go to Top of Page

jedi_knight
Starting Member

USA
6 Posts

Posted - 05/30/2012 :  09:45:48  Show Profile  Reply with Quote
I debugged the code and found that CURRENT DATE worked. Thank you for your help. The code is working.


quote:
Originally posted by khtan

try

CURRENT DATE


KH
Time is always against us



Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000