Generating Records of all date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear MVPs,

I have one Query as below,

Query1:

EquID StartuseDay EnduseDay TotalMonths MonthDepreciation
E0001 2002-6-15 2007-6-14 60 $10,000

it is an examples of one record,

i need to generating another query show below datas base on this record,

EquID Dates MonthDepreciation
E0001 2002-6-14 $10,000
E0001 2002-7-14 $10,000
E0001 2002-8-14 $10,000
.....
E0001 2007-6-15 $10,000

the records date is one month add one by one till 60 months,
Waiting for your kind response!
 
You need another table. That table should have one column of numbers (1 to
60 or whatever the maximum number of months might be).

Now you can use that table and your original query with no join.

SELECT EquiID
, DateAdd("m",1-NumbersTable.NumberColumn,EndUseDay) as Dates
, MonthDepreciation
FROM [Your Original Query] as A, NumbersTable
WHERE NumbersTable.NumberColumn <=A.TotalMonths
ORDER BY DateAdd("m",1-NumbersTable.NumberColumn,EndUseDay)
 
Oh, Wonderfully, i achieved what i want,
Thank yo so much, John,

--
Best Regards
Xuehong


John Spencer said:
You need another table. That table should have one column of numbers (1 to
60 or whatever the maximum number of months might be).

Now you can use that table and your original query with no join.

SELECT EquiID
, DateAdd("m",1-NumbersTable.NumberColumn,EndUseDay) as Dates
, MonthDepreciation
FROM [Your Original Query] as A, NumbersTable
WHERE NumbersTable.NumberColumn <=A.TotalMonths
ORDER BY DateAdd("m",1-NumbersTable.NumberColumn,EndUseDay)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top