Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select/Insert Same Table With Modified DateTime

Status
Not open for further replies.

HestonJames

Programmer
Aug 11, 2008
187
GB
Hello Guys,

I have a tables which looks somewhat like this:

CustomerTransaction
----------------------
CustomerTransaction_ID - Int - PK - Identity
Customer_ID - Int
Description - Varchar
TransactionDateTime - DateTime

What I want to do is given a datetime range and a customer_id INSERT records into the table which are the same as records one month prior to that range.

So, for instance if I'm given the following datetimes:

22/01/2008 08:00
28/01/2008 16:00
Customer_ID = 41

The I want it to SELECT all the records for that datetime range but -1 month (22/12/2007 08:00 - 28/12/2007 16:00) for that customer_id, and then INSERT them into the table but within the daterange above.

What's the best way to achieve this? If you have any questions guys then please let me know :)

Heston
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top