Dates in OQL

3 posts, 0 answers
  1. Robert
    Robert avatar
    6 posts
    Member since:
    Sep 2008

    Posted 27 Feb 2009 Link to this post

    Hello All,

    How do you represent dates in an OQL Query?

    i.e. somthing like  select * from classextent where DueDate>???????

  2. PetarP
    PetarP avatar
    754 posts

    Posted 27 Feb 2009 Link to this post

    Hi Robert,
    the best wayis to pass it as a parameter like:
    IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope(); 
                string query = "select * from EmployeeExtent as x where x.BirthDate> $1"
                var result = scope.GetOqlQuery(query).Execute(DateTime.Parse("1/1/1962")); 
                foreach (Employee emp in result) 
                    Console.WriteLine( emp.BirthDate); 

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Majid
    Majid avatar
    9 posts
    Member since:
    Dec 2008

    Posted 31 Mar 2009 Link to this post




    query = "...........  X.startTime >= timestamp '" + date.ToString("yyyy-MM-dd HH:mm:ss") + "' AND X.startTime < timestamp '" + date.Add(new TimeSpan(1,0,0,0)).ToString("yyyy-MM-dd HH:mm:ss") + "' ORDER BY X.startTime DESC";

    This will work. To find any thing on specific date. For your program adjust it your self.







Back to Top