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.
Author |
Topic |
angela_g
Starting Member
17 Posts |
Posted - 2013-09-19 : 06:59:05
|
Hi im trying to create an SQL to find members who joined more then 12 months ago, can anyone help me with this please? This is what I have so far...SELECT RE_EZPAY_AT_AGENCY_DAILY.SNAPSHOT_DATE, RE_EZPAY_AT_AGENCY_DAILY.AGG_ORDER_NO, RE_EZPAY_AT_AGENCY_DAILY.DEBT, RE_EZPAY_AT_AGENCY_DAILY.MEMBER_NO_WCD, RE_EZPAY_AT_AGENCY_DAILY.STATUS, VE_MEMBER.MEMBER_JOIN_DATEFROM RE_EZPAY_AT_AGENCY_DAILYINNER JOIN VE_MEMBERON RE_EZPAY_AT_AGENCY_DAILY.MEMBER_NO = VE_MEMBER.MEMBER_NOWHERE VE_MEMBER.MEMBER_JOIN_DATE |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-09-19 : 07:04:56
|
WHERE ... < DATEADD(YEAR, -1, GETDATE()) Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-09-19 : 07:06:40
|
WHERE VE_MEMBER.MEMBER_JOIN_DATE < dateadd(month,-12,getdate()) Too old to Rock'n'Roll too young to die. |
|
|
angela_g
Starting Member
17 Posts |
Posted - 2013-09-19 : 07:28:29
|
Thankyou both for your help...Im getting an error message... wondering if it could be something to do with the date format SELECT RE_EZPAY_AT_AGENCY_DAILY.SNAPSHOT_DATE, RE_EZPAY_AT_AGENCY_DAILY.AGG_ORDER_NO, RE_EZPAY_AT_AGENCY_DAILY.DEBT, RE_EZPAY_AT_AGENCY_DAILY.MEMBER_NO_WCD, RE_EZPAY_AT_AGENCY_DAILY.STATUS, VE_MEMBER.MEMBER_JOIN_DATEFROM RE_EZPAY_AT_AGENCY_DAILYINNER JOIN VE_MEMBERON RE_EZPAY_AT_AGENCY_DAILY.MEMBER_NO = VE_MEMBER.MEMBER_NOWHERE VE_MEMBER.MEMBER_JOIN_DATE <DATEADD(YEAR, -1, GETDATE())ORA-00904: "DATEADD": invalid identifier00904. 00000 - "%s: invalid identifier"*Cause: *Action:Error at Line: 11 Column: 35 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-09-19 : 07:30:26
|
we are on MS SQL Server only here that's why our solutions will not work for you.Better try to get help in an oracle forum Too old to Rock'n'Roll too young to die. |
|
|
sigmas
Posting Yak Master
172 Posts |
Posted - 2013-09-19 : 08:07:22
|
>>WHERE VE_MEMBER.MEMBER_JOIN_DATE <DATEADD(YEAR, -1, GETDATE())try this:WHERE VE_MEMBER.MEMBER_JOIN_DATE < sysdate - INTERVAL '1' year(1) |
|
|
sigmas
Posting Yak Master
172 Posts |
Posted - 2013-09-19 : 08:15:15
|
In Oracle like SQL Server you can use arithmetic operator for date value.For adding -365 days for current date enough to use this: sysdate - 365 |
|
|
angela_g
Starting Member
17 Posts |
Posted - 2013-09-19 : 09:05:26
|
ah i see webfred...thanks :)Obrigada sigmas PERFECT ;) |
|
|
|
|
|
|
|