Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

LINQ DatetimeProblem in Sharepoint

Posted on 2011-03-10
8
Medium Priority
?
681 Views
Last Modified: 2012-05-11
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;
0
Comment
Question by:LuisEstebanValencia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 14

Accepted Solution

by:
GeorgeGergues earned 2000 total points
ID: 35095826
Use the Convert .NET utility to set your types.
Does that work.


var articlesqry = from row in articles
                                  where row.ItemLanguage.ToString() == (WebPart.Language == null ? DefaultLanguage : Language)
                                  && row.PromoteToFront == true
                                  //&& Convert.ToDateTime(row.PublicationDate) >= DateTime.Today
                                  orderby row.PublicationDate descending
                                  select row;

BEst of Luck
0
 

Author Comment

by:LuisEstebanValencia
ID: 35096894
NO, that doesnt work, it filters me out everything., why would I convert a datetime field again to datetime?

0
 
LVL 14

Expert Comment

by:GeorgeGergues
ID: 35096920
are you sure it is DateTime ?

At DEbug .

track those values on the debug window and see the values.
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:LuisEstebanValencia
ID: 35097654
Yes Its I have been developing for 9 years in .net! and it seems that sharepoint just treats date values in a different format.
0
 
LVL 14

Expert Comment

by:GeorgeGergues
ID: 35097679
well , did you manage to convert to DateTime ?
0
 

Author Comment

by:LuisEstebanValencia
ID: 35099796
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
0
 
LVL 14

Expert Comment

by:GeorgeGergues
ID: 35099910
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.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDate
Time


Try it .
0
 

Author Comment

by:LuisEstebanValencia
ID: 35107082
I think that method returns a string, I am not in the office but I will try that later.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question