This is a migrated thread and some comments may be shown as answers.

Dates in OQL

2 Answers 213 Views
OQL (OQL specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Robert
Top achievements
Rank 1
Robert asked on 27 Feb 2009, 11:27 AM
Hello All,

How do you represent dates in an OQL Query?

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

2 Answers, 1 is accepted

Sort by
0
PetarP
Telerik team
answered on 27 Feb 2009, 12:21 PM
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"
            scope.Transaction.Begin(); 
            var result = scope.GetOqlQuery(query).Execute(DateTime.Parse("1/1/1962")); 
            foreach (Employee emp in result) 
            { 
                Console.WriteLine( emp.BirthDate); 
            } 
            scope.Transaction.Commit(); 
            scope.Dispose(); 
            Console.ReadKey(); 


Best wishes,
PetarP
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.
0
Majid
Top achievements
Rank 2
answered on 31 Mar 2009, 01:17 PM
 

 

 

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.

 

 

 

 

 

 

Tags
OQL (OQL specific questions)
Asked by
Robert
Top achievements
Rank 1
Answers by
PetarP
Telerik team
Majid
Top achievements
Rank 2
Share this question
or