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
 SQL Server Development (2000)
 last month records

Author  Topic 

asad_siddiqui
Starting Member

1 Post

Posted - 2007-09-12 : 06:51:18
hello,

i want to show last month records from current date.
What will be the query for that

thanks,

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-12 : 06:56:35
[code]SELECT {column name list here}
FROM Table1
WHERE {datetime column name here} >= DATEADD(MONTH, DATEDIFF(MONTH, 31, CURRENT_TIMESTAMP), 0)
AND {datetime column name here} < DATEADD(MONTH, DATEDIFF(MONTH, 0, CURRENT_TIMESTAMP), 0)[/code]Also see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86769



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -