DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Last Full Month

  1. #1
    Join Date
    Oct 2004
    Posts
    2

    Last Full Month

    Hello, I'm trying to write a MS-DTS Script that will connect to my Oracle 8i server and download data for the last full month.

    In my Table I have a table "SW_CASE" I have a column named: "SWDATECREATED".
    It store the data the following way:

    2004-09-02 08:57:12

    What I need is a way to tell it I Only need the rows from the last full month. I don't want to have to change the date every time I co to run this query.

    I've tried the following only to get a syntax error:

    Code:
    SW_CASE."SWDATECREATED" >= DATEADD(mm,DATEDIFF(mm,0,SYSDATE())-1,0) AND
    SW_CASE."SWDATECREATED" < DATEADD(mm,DATEDIFF(mm,0,SYSDATE()),0))

    Any Ideas?

    Fishbone34

  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    You'll need to mess around with add_months and trunc. It will be something like add_months(trunc(sysdate,'mm'),-1) to trunc(sysdate,'mm')-1
    Jeff Hunter

  3. #3
    Join Date
    Oct 2004
    Posts
    2

    Worked like a charm.

    Thanks Jeff, It works!

    fishbone34

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width