Filtering DateTime

Posts   
 
    
Matos
User
Posts: 1
Joined: 07-Oct-2005
# Posted on: 07-Oct-2005 18:54:06   

Hi, i'm having problems filtering DateTime Fields in tables, since SQL views dates as:

Jul 3 1991 12:00AM

I'm using C# code, and my dates are in Date.Time format. (01/01/1900) Is there any simple way, whitout hard-coded implement the decoding of the Date.Time object?

Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 07-Oct-2005 20:37:35   

Use the DateTimeField's Date property to get the Date with the time set to 00:00:00.

moftol
User
Posts: 2
Joined: 18-Oct-2007
# Posted on: 14-Nov-2007 08:24:31   

i also have the problem of filtering data on the basis of date and time please explain in little bit clear wordssimple_smile simple_smile

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 14-Nov-2007 10:30:24   

Hi, i'm having problems filtering DateTime Fields in tables, since SQL views dates as:

Jul 3 1991 12:00AM

I'm using C# code, and my dates are in Date.Time format. (01/01/1900) Is there any simple way, whitout hard-coded implement the decoding of the Date.Time object?

If you want to execlude the time part on the database, you may use a DBFunctionCall to call for the SQL Server Function DATEPART() to use the DATE part only.

Makhaly_cs avatar
Makhaly_cs
User
Posts: 27
Joined: 12-Jan-2009
# Posted on: 30-Mar-2010 11:32:51   

What i can do to get only the Day part and the Month part of the DateTime Field with oracle database?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Mar-2010 11:54:57   

Use a DBFunctionCall to the appropriate Oracle function.

next time, please start a new thread, rather than using an old one.

Makhaly_cs avatar
Makhaly_cs
User
Posts: 27
Joined: 12-Jan-2009
# Posted on: 30-Mar-2010 12:20:04   

Thanks alot Walaa

I have wrote the following code and works fine.

EntityField dayField = new EntityField("Day", new DbFunctionCall("To_Char", new object[] { CustomerFields.BirthDate, "DD" }));
                    EntityField monthField = new EntityField("Month", new DbFunctionCall("To_Char", new object[] { CustomerFields.BirthDate, "MM" }));

                    filter.Add(dayField == BirthDateTimePicker.Value.Day);
                    filter.Add(monthField == BirthDateTimePicker.Value.Month);