Alfredomulet
MIS
Hello everyone. I need to filter my query based upon the record date (RecordDate = day at the end of the month where the specific table was loaded).
This recorddate can be different depending on the source file, so, for August 2005 I might have a file loaded on August 25th into one table, and another file on August 31st into another table. There is just one load per table per month.
When making joins into these tables to obtain the most recent record, I'm using:
so it allways chooses the date of the current month where it was loaded the table.
Is it there a more effective way of doing this?
Cheers,
Alfredo
This recorddate can be different depending on the source file, so, for August 2005 I might have a file loaded on August 25th into one table, and another file on August 31st into another table. There is just one load per table per month.
When making joins into these tables to obtain the most recent record, I'm using:
Code:
...
WHERE AHC.Recorddate >= DateAdd(month,-1,CAST(Year(GetDate()) as varchar) + '-' + CAST(Month(GetDate()) as varchar) + '-01')
AND AHC.Recorddate <= DateAdd(day,-1,CAST(Year(GetDate()) as varchar) + '-' + CAST(Month(GetDate()) as varchar) + '-01')
...
so it allways chooses the date of the current month where it was loaded the table.
Is it there a more effective way of doing this?
Cheers,
Alfredo