SharePoint get dates like they should…

Working with dates is just always complicated and it is always an issue, in SharePoint it can be even worse, you retrieve a date and is just off by a date????
To make sure you retrieve the dates correctly you can use this method, I would make an extensions method for it, but here is is:

CamlQuery Modified times

Sometimes you just needs items that have been updated in a certain period of time.
You can do this with a CamlQuery, in this example I’m looking for items that have been modified in the last 80 minutes;
Basically you generate a DateTime object and format it to the right format.
Also look at the ‘IncludeTimeValue’ option of the query…

 <View Scope='RecursiveAll'><Query><Where><Gt><FieldRef Name='Modified'/>
<Value  IncludeTimeValue='TRUE'  Type='DateTime'>" + datetime + "</Value></Gt></Where>><OrderBy><FieldRef Name='Modified' Ascending = 'true' /></OrderBy></Query></View>