Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Question Unanswered: Getting the correct "Date" problem?

    In a procedure that I am writing I have a select statement and need to say give me such and such results from the table where DateEntered is the first of the previous month??

    Could somebody help me with that please?

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I can get you to the "first of the prior month", but you'll have to do the dirty deed from there on in. I'd use:
    Code:
    SELECT DateAdd(month, -1, Convert(CHAR(8), GetDate(), 121) + '01')
    -PatP

  3. #3
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    Well that is great!!!!

    This procedure will run a query once a month in the background,how can capture that data in a file and save it on my pc without doing it manually???
    Last edited by zobernjik; 05-19-04 at 01:33.

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Use OSQL.EXE to execute the stored procedure. You may want to start osql.exe from a job in the SQL Agent.

    -PatP

  5. #5
    Join Date
    Jan 2003
    Location
    India
    Posts
    523
    Quote Originally Posted by zobernjik
    This procedure will run a query once a month in the background,how can capture that data in a file and save it on my pc without doing it manually???
    configure a job which runs monthly which does this for you.

Posting Permissions

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