LuisEstebanValencia
asked on
LINQ DatetimeProblem in Sharepoint
I have the following code, the commented line is the line that filters out all the rows I need, and its always returning me zero.
The PublishingDate is a date field in sharepoint, I just wonder how is the best way to fix the date issue, I guess that the date in sharepoint format is different than in the variable datetime.today
var articlesqry = from row in articles
where row.ItemLanguage.ToString( ) == (WebPart.Language == null ? DefaultLanguage : Language)
&& row.PromoteToFront == true
//&& row.PublicationDate >= DateTime.Today
orderby row.PublicationDate descending
select row;
The PublishingDate is a date field in sharepoint, I just wonder how is the best way to fix the date issue, I guess that the date in sharepoint format is different than in the variable datetime.today
var articlesqry = from row in articles
where row.ItemLanguage.ToString(
&& row.PromoteToFront == true
//&& row.PublicationDate >= DateTime.Today
orderby row.PublicationDate descending
select row;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
are you sure it is DateTime ?
At DEbug .
track those values on the debug window and see the values.
At DEbug .
track those values on the debug window and see the values.
ASKER
Yes Its I have been developing for 9 years in .net! and it seems that sharepoint just treats date values in a different format.
well , did you manage to convert to DateTime ?
ASKER
ITS A DATETIME, there is no need to convert to datetime a variable that is already datetime, and yes I even tried and it doesnt work because both fields are in different format, datetime.today doesnt have the same format of the sharepoint date values
that is my point it is not a DateTime type
You have to convert that to DateTime or convert your DateTime to SharePoint Time
You can use this Utility
Microsoft.SharePoint.Utili ties.SPUti lity.Creat eISO8601Da teTimeFrom SystemDate
Time
Try it .
You have to convert that to DateTime or convert your DateTime to SharePoint Time
You can use this Utility
Microsoft.SharePoint.Utili
Time
Try it .
ASKER
I think that method returns a string, I am not in the office but I will try that later.
ASKER