4 Replies - 831 Views - Last Post: 24 October 2012 - 02:31 AM Rate Topic: -----

#1 student123  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 77
  • Joined: 18-November 08

sql task on how to select the last month question

Posted 16 October 2012 - 08:28 AM

i have been asked to help in a sql project we are using crystal at the moment to select the last month and i hope that some one would help with the sql slection of the lastfullmonth



 where left ((convert(varchar,[ship,date],122),1) = left (convert(varchar(datedd(month,12,getdate()),1120,6) 


any help would be greatly appreciated

This post has been edited by student123: 16 October 2012 - 08:43 AM

Is This A Good Question/Topic? 0
  • +

Replies To: sql task on how to select the last month question

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10649
  • View blog
  • Posts: 39,548
  • Joined: 27-December 08

Re: sql task on how to select the last month question

Posted 16 October 2012 - 08:46 AM

Moved to Databases.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9383
  • View blog
  • Posts: 35,228
  • Joined: 12-June 08

Re: sql task on how to select the last month question

Posted 16 October 2012 - 08:48 AM

Would you rewrite that question? It is not clear on what you want.
Was This Post Helpful? 0
  • +
  • -

#4 student123  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 77
  • Joined: 18-November 08

Re: sql task on how to select the last month question

Posted 16 October 2012 - 08:58 AM

sorry

i am using softer where called Crystal 2008 and it can select the last full mont.

i need to bring in all jobs that where done from the last month and i need to qrey the date bais for this info
Was This Post Helpful? 0
  • +
  • -

#5 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: sql task on how to select the last month question

Posted 24 October 2012 - 02:31 AM

i am not sure, just a suggesstion
use on of the following
WHERE MONTH (CreatedOn) <= MONTH (DATEADD (YEAR, 1, GETDATE())) AND
           YEAR (CreatedOn) <= YEAR (GETDATE()) + 1


or
CONVERT (VARCHAR, DATEADD (MONTH, 12, GETDATE()), 112) = CONVERT (VARCHAR, createdon, 112)



put shipdate instead of createdon
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1