Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Query For DTS

Author  Topic 

dalmond
Starting Member

2 Posts

Posted - 2008-04-01 : 14:45:53
I'm tring to create a query in DTS that pulls into a table the last 60 days of data from an ODBC connection. This query works when creating a view, but errors in DTS. Here is my query:

SELECT CHG_DATE, CHG_SERVICE_DATE, CHG_CHARGE_NUMBER, CHG_QUANTITY, CHG_AMOUNT, CHG_INITIALS
FROM od_ar_charges
WHERE (CHG_DATE >= dateadd(d,datediff(d,0,getdate()),-60))
ORDER BY CHG_DATE
.

I get an error that says...Expected lexical element not found

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-04-01 : 15:19:32
Check this out:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=63511 id="Book Antiqua">
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-04-01 : 22:46:34
Correct dateadd usage is dateadd(d, -60, getdate()). By the way, what's purpose of datediff(d, 0, getdate())?
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2008-04-02 : 02:22:47
It gets rid of the time.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-04-02 : 21:53:25
Not really, looks like give you number of days between today and 1900-01-01.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2008-04-03 : 06:40:32
Which gets implcitely converted to a datetime and as the first part of the datetime is the number of days from 19000101 it will just get rid of the time.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-04-03 : 22:07:41
Not sure why OP needs that number in the query.
Go to Top of Page

dalmond
Starting Member

2 Posts

Posted - 2008-04-07 : 16:06:25
Thanks for info! I got what I needed by using CHG_DATE >={fn CURDATE()} -60
Go to Top of Page
   

- Advertisement -