Filter By TimeStamp

Posts   
 
    
saravana
User
Posts: 63
Joined: 11-Nov-2010
# Posted on: 22-Nov-2011 20:05:56   

Hi,

I have an AccessEvent table which has a TimeStamp field. I have a related table which is linked by the ID and TimeStamp field. I need to filter the linked table data by Id and TimeStamp field values. I need to pass the value "20-NOV-11 01.14.05.679247000 PM" from UI(C#) to LLBLGen filter expression.

How can I pass the above Timestampe value via a BL method and process the value via LLBLGen Filter? ( I am using selfservicing).

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Nov-2011 04:21:02   

You should parse the value to obtain a DateTime and use it in the filter:

...
var dateTimeToFilter = DateTime.Parse(mySqlTimestamp);
filter.Add(AccessEventFiels.SomeTimestamp == dateTimeToFilter);
...
David Elizondo | LLBLGen Support Team
saravana
User
Posts: 63
Joined: 11-Nov-2010
# Posted on: 23-Nov-2011 11:43:45   

I have tried like above. But the query didn't return any values. This is due to the C# conversion of TimeStamp values. It is only taking upto the seconds and not considering the Milliseconds in the input date. Even If I Pass as string and try to convert using ToString() of the value "22-NOV-11 01.13.05.679247000 PM", The C# doesn't recongnise the string as valid DateTime. Is another way around for this? based on the MSDN document it seems that C# support milliseconds upto the precision of 7 digits.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 23-Nov-2011 15:02:28   

Filtering with DatTime with Milliseconds can be problamatic.

You may use a DBFunctionCall to convert a string representation of the DateTime value to a database Date type.