.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

Compare Date in LINQ

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
 
Dear all, How to do in LINQ?? And below is correct or not if put string.format in LINQ??   Datetime updatedDate=DateTime.Now; string upddate=string.format("yyyy-MM-dd", updatedDate); var result=( from p in W_Order                   where string.format("yyyy-MM-dd", p.orderdate) == upddate                    select new order {                       .........                        }).toList();            


View Complete Post


More Related Resource Links

Converting Date to String and Formating it Linq to SQL

  
Hello I have problem in converting date to string I am using cstr(p.tripstart) , which is returning Date as 12 Aug 2010 12:AM   I need to make formating   This is my code : Dim db As New TripsLinqDataContext Dim listtrips = (From p In db.Trips _ Group Join c In db.Countries On p.TripCountryID Equals c.TripCountryID Into countrylist = Group _ Select New With {.Tripdetails = p.TripDescription + " - " + p.TripCityList + " - " + CStr(p.tripstart) + " - " + CStr(p.TripDays), _ .Tripid = p.TripID}).ToList tripboxlist.DataSource = listtrips tripboxlist.DataTextField = "Tripdetails" tripboxlist.DataValueField = "Tripid" tripboxlist.DataBind()     Regards  

How to use compare validator with dd/MM/yyyy format of date

  
Hi all,  I have a form of leave application that has 2 dates, start date and end date. now i'm using the dd/MM/yyyy format for the date entry and i need to Validate end date like end date must me greater than or equal to start date. i want to do that with compare validator but its not working properly because of the Date  formats controls are using.    Currently i'm using textbox with Calendar extender ajax toolkit control.    So please help me if anybody have some hints.    Thanks in advance.

how do it i created a Grid view that contain onecoloum Expiredate a i require the date compare to

  

i created a Grid view that contain onecoloum Expiredate a  i require the date compare to today date if it is

if
  Todaydate<=Expiredate (difference 30 days then color is red
  Todaydate<=Expiredate (difference 15 days then color is blue
  Todaydate<=Expiredate (difference 5 days then color is yellow
 
    example
    id Expire date  Filename
    1  22/08/10      a(Red )   
    2  22/09/10     b(yellow )
    3  8/09/10      c(green  )
    
    how do it


MDX IIF Statement to compare Moday's Date

  

Hi, I basically want to caluate the previous week

Using

SELECT Tail(NonEmptyCrossJoin([Dim Date].[Year-Week].[Week Of Year])).Item(0).Item(0).lag(1) ON 0
FROM OLAP_Cube

However, if it's a Sunday then it should be:

SELECT Tail(NonEmptyCrossJoin([Dim Date].[Year-Week].[Week Of Year])).Item(0).Item(0) ON 0
FROM OLAP_Cube

So what I did was the following:

    SELECT IIF(Tail(NonEmptyCrossJoin([Dim Date].[Year-Quarter-Month-Day].[Day Of Week])).&[7]
                ,Tail(NonEmptyCrossJoin([Dim Date].[Year-Week].[Week Of Year])).Item(0).Item(0).lag(1)
                ,Tail(NonEmptyCrossJoin([Dim Date].[Year-Week].[Week Of Year])).Item(0).Item(0)
                ) ON 0
    FROM OLAP_Cube


However, I get The syntax for '&' is incorrect.

Any ideas?

Thanks

Bob

 

 

 

 

 

 


How to compare two different structure datatable by using LINQ

  

Hi

   i have following senario in my application

DataTable1 have following structure

Dependencies                                      Tolerance

Workflow1 Lorem1 lpsum           150     

Workflow2 Lorem1 lpsum            25

 

DataTable 2

Dep_Type         

How to retrive a date time value from TimeStamp column using Linq?

  

I have a Timestamp column in my Table. I want to read the date time value and display in UI.

In Linq the Timestamp column is represented as System.Data.Linq.Binary.

I dont know how to retirve date time value in "MM-dd-YYYY" format from this Linq.Binary

 

- Why I am using Timestamp?.

I want to perform some operations based on the last modified date time of the particular row. Since I am using TimeStamp column in my Table as version column, It will contain the last modified date details, So i want to read the date time value from this time stamp column to do some other operations.

 

 


LINQ - XML - DATE

  

        XDocument doc = XDocument.Load("http://localhost:49545/Default/XMLFile2.xml");

        var data = from c in doc.Descendants(XName.Get("tecajnica")).Descendants()
                   //where c.Attribute("oznaka").Value == "USD"
                   where c.Attribute("oznaka").Value == "USD" && c.Attribute("sifra").Value == "840"
                
                   select new
                   {

                       oznaka = c.Attribute("oznaka").Value,
                       sifra = c.Attribute("sifra").Value,
                   };

        GridView1.DataSource = data;
        GridView1.DataBind();

<bookstore xmlns:bk="urn:samples">
  <tecajnica datum="2010-10-21">
    <tecaj oznaka="USD" sifra="840">1.4016</tecaj>
    <tecaj oznaka="JPY" sifra="392">113.65</tecaj>
    <tecaj oznaka="BGN" sifra="975">1.9558</tecaj>
    <tecaj oznaka="CZK" sifra="203">24.540</tecaj>
    <tecaj oznaka="DKK" sifra="208">7.4584</tecaj>
    <tecaj oznaka="EEK" sifra="233">15.6466</tecaj

Find the nearest date before Saturday, Sunday and holidays with Linq

  

 var tecaji = (from xml in doc.Descendants(slazhnmaespace + "tecajnica")
                      where xml.Attribute("datum").Value == "2010-10-158"
                      select xml).Elements().Where(a => a.Attribute("oznaka").Value.Equals("TRY")).Select(n => n.Value).SingleOrDefault();

I have dates that are not in the XML file, but value still has to show.

In the table there is no value for the date of 23.10.2010, 24.20.2010. How do you show value for the date 10/22/2010?

Finding the appropriate date, which is najbluzjemu to that in the table.

In this XML table is not displayed dates (Saturday - Sunday).

Therefore, to find the nearest date before Saturday and Sunday.

Example:
If it is Saturday, the date "02.10.2010" shall be the date of "01/10/2010.

How do I get to that solution?


Thanks


How to get the Nearest date with Linq

  

            var querysnajblizjidatum = (from xml in doc.Descendants(slazhnmaespace + "tecajnica")
                          where xml.Attribute("datum").Value == datumstroska.ToString("yyyy'-'MM'-'dd")
                                      //  where xml.Attribute("Datum").Value.Equals("10-21-2010") //< najblizjidatum 
                                        where (xml >= xml.Attribute("Datum").Value >= "10.5.2010")  
                          select xml).Elements().Where(a => a.Attribute("oznaka").Value.Equals(ddlValutaStroska.SelectedValue.Substring(0, 3))).Select(n => n.Value).SingleOrDefault();


How to get the Nearest date? My code does work.

Example:
15.10.2010
18.10.2010
25.10.2010
8.11.2010


If the date of 16.10.2010, I want print, 15.10.2010

If the date of 21.10.2010, I want print, 18.10.2010

If the date of 19.11.2010, I want print, 8.11.2010

etc...


Thanks.


Nearest date with Linq

  

Hi,

If I choose the date 10.02.2010 and there is none, I want to find the earliest date.

Example:
1.10.2010
5.10.2010
10.10.2010
15.10.2010


Find a date that does not exist, it is 03.10.2010.
Given that the date in the table does not exist, I want to find 1.10.2010.

If I want to find 20.10.2010 and it does not find, print 15.10.2010.

itc..

How do I find nearest date with LINQ, if I can not find?


compare date field in sharepoint designer without considering time

  

Hi

I  set date1 field in sharepoint designer with “set field in current item” action. And in next step I want to compare date1 with another date field. With “if date1 not equal to date2”

although I set  “Date & Time Format” to “Date only”, my problem is sharepoint designer consider time ( although my condition is true ,I think its compare the time of my date field and cant go next step) and I don’t want it. I want to compare date filed only with date,

what should I do, that sharepoint designer only consider Date in Date field in action?

Thanx a lot.

SharePoint Designer Workflow - how to compare the Items if it is modified date is older than 20 days

  

I have a workflow which will keep track of specific meta data selection for a Custom List, as soon as an item gets updated to a specific selection say it as Resolved, I am sending an email to an user.

 

But after this I will need to check for every item in the list that If an item gets resolved and older than 20 days, I will have to move this item to a different list. I can get the resolved item date, store it an variable, but from here I will need to check if the item is older than 20 days and if it is this needs to be moved.

My point is the work-flows will be fired only when an item gets changed or updated, how to keep track of every item in the list and automatically move the older items without any manual intervention.

 

Am I clear in my requirement, if not kindly let me know.


If you have knowledge, let others light their candles in it.

Playing with Linq grouping: GroupByMany?

  
One of its features is grouping. Many people understand grouping like it is defined in Sql. Linq is implementing grouping quite the same way. Let's discover this syntax and how to make consecutive groups easier.

LINQ : Implementing IN and NOT IN

  
I got tried of typing

var result = from s in source
where items.Contains(s)
select s;and so I implemented the IN and NOT IN methods as extension methods:

101 LINQ Samples Tutorials

  
101 LINQ Example with sample code snippets....This sample prints each element of an input integer array whose value is less than 5. The sample uses a query expression to create a new sequence of integers and then iterates over each element in the sequence, printing its value

Using a CompareValidator to check input is a valid date

  
The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

Linq: how to share parameters between lambda expressions ?

  
When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it's not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not visible from one method to another.
The compiler is using two technical different ways to let parameters go out of a method.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend