Quantcast
Channel: SharePoint – SharePointed
Viewing all articles
Browse latest Browse all 69

CAML Query to Return Items Less Than or Greater Than Now

$
0
0
Quick example how to query a list or library for items created more than 5 minutes ago. You can use the Get-Date cmdlet to increment all sorts of values.


$nowMinus5Minutes = [Microsoft.SharePoint.Utilities.SPUtility]::CreateISO8601DateTimeFromSystemDateTime((Get-Date).AddMinutes(-5))
$nowPlus5Minutes = [Microsoft.SharePoint.Utilities.SPUtility]::CreateISO8601DateTimeFromSystemDateTime((Get-Date).AddMinutes(5))

#get items created less than 5 minutes ago
		$caml = '<Where><Lt><FieldRef Name="Modified" /><Value Type="DateTime">' + $nowMinus5Minutes + '</Value></Lt></Where>'
		$sQuery.Query = $caml

Viewing all articles
Browse latest Browse all 69

Trending Articles