I'm entering this discussion a bit late, but for reference you can use a single web part to filter by dates with a default date range.
The key is that you can pass a either a value or a CAML fragment as a parameter in a DVWP
The solution is:
- Create a calculated column "CreatedPlus30"
- Since we can't subtract from the querystring parameter, we must add to the created field instead
- Create a querystring parameter in the DVWP which will filter on the date field.
- Set the default value of the parameter to the Today CAML variable.
<ParameterBinding Name="DateFrom" Location="QueryString(DateFrom)" DefaultValue="<Today/>"/>
The data will then be filtered by the querystring parameter only if it exists, otherwise by the current date (adjusted for your offset)
Detail and code samples for your question above:
Create a calculated column "CreatedPlus30" - Since we can't subtract from the querystring parameter, we must add to the created field instead
To get items created in the last 30 days you would use the following CAML fragment:
<Geq><FieldRef Name="Created"/><Value Type="DateTime"><Today OffsetDays="-30"/></Value></Geq>
We will offset by 30 days:
<Geq><FieldRef Name="CreatedPlus30"/><Value Type="DateTime"><Today/></Value></Geq>
You can also use this field to compare against a date value with the following CAML fragment:
<Geq><FieldRef Name="CreatedPlus30"/><Value Type="DateTime">yyyy-MM-ddTHH:mm:ssZ</Value></Geq>
We now have 2 queries filtering on the same field, where the "value" portion of the query is yyyy-MM-ddTHH:mm:ssZ
or <Today/>
Encoding the CAML fragment so we can use in the DVWP data source select command, this is our final parameter:
<ParameterBinding Name="DateFrom" Location="QueryString(DateFrom)" DefaultValue="<Today/>"/>
This is our final parameterized CAML fragment:
<Geq><FieldRef Name="CreatedPlus30"/><Value Type="DateTime">{DateFrom}</Value></Geq>
Encoded for the DVWP data source query:
<Geq><FieldRef Name="Created"/><Value Type="DateTime">{DateFrom}</Value></Geq>