Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Search based on Insertion time
System
I am trying to search for assets that fall under certain date period,for example I have to search for assets between from date(10/3/2006) to to date(10/5/2006). Problem here is how do I set Metadata Type as DateTime in Search criteria.
Also wanted to know how to create a search constraint when MBBooleanOperator is set to MBBooleanOperator.AND as I have to search between two dates.
canybody help!!!
Thanks
Find more posts tagged with
Comments
msrinivas
What you are trying to do is a customer search and that would be available if you enable the advanced search feature in MB.
HTH
msnider
You'll want to do something like this:
public void SearchDateRange( System.DateTime startDate, System.DateTime endDate )
{
...
MBMetadata metadata1 = new MBMetadata();
metadata1.mName = "Modified Time";
metadata1.mID = "{B297C573-F083-11D4-8200-0060080D8AC2}";
metadata1.mValue = startDate;
MBMetadata metadata2 = new MBMetadata();
metadata2.mName = "Modified Time";
metadata2.mID = "{B297C573-F083-11D4-8200-0060080D8AC2}";
metadata2.mValue = endDate;
criteria.mSearchConstraints = new MBSearchConstraint[2];
criteria.mSearchConstraints[0] = new MBSearchConstraint();
criteria.mSearchConstraints[0].mMetadata = metadata1;
criteria.mSearchConstraints[0].mSearchOperator = "GreaterThan";
criteria.mSearchConstraints[0].mBooleanOperator = MBBooleanOperator.AND;
criteria.mSearchConstraints[1] = new MBSearchConstraint();
criteria.mSearchConstraints[1].mMetadata = metadata2;
criteria.mSearchConstraints[1].mSearchOperator = "LessThan";
...
}
Mark
lyman
One point that sometimes confuses people doing date-based searches, is that MediaBin stores the time to the second and not just date. Therefore, to determine if something happened on a given day, you want to compare to midnight of the following day. Similarly for a one day range the appropriate comparison is >= midnoght of that day and < midnight of the following day. In particular, straight = comparisons of dates are seldom useful.
Cheers,
Lyman Hurd
Migrateduser
I tried using this method to return a range based on Insertion Time with a 0 result count back.
Can you offer any suggestions?
MBSearchConstraint[] mbSearchConstraints = new MBSearchConstraint[2];
MBMetadata metadata1 = new MBMetadata();
metadata1.mName = "Insertion Time";
metadata1.mID = "{B297C573-F083-11D4-8200-0060080D8AC2}";
metadata1.mValue = "1/1/1999";
MBMetadata metadata2 = new MBMetadata();
metadata2.mName = "Insertion Time";
metadata2.mID = "{B297C573-F083-11D4-8200-0060080D8AC2}";
metadata2.mValue = "6/2/2007";
mbSearchConstraints[0] = new MBSearchConstraint();
mbSearchConstraints[0].mMetadata = metadata1;
mbSearchConstraints[0].mSearchOperator = "GreaterThan";
mbSearchConstraints[0].mBooleanOperator = MBBooleanOperator.AND;
mbSearchConstraints[1] = new MBSearchConstraint();
mbSearchConstraints[1].mMetadata = metadata2;
mbSearchConstraints[1].mSearchOperator = "LessThan";
msnider
Hi Stacy,
You'll need to specify the values as System.DateTime instead of strings....you can use the Parse method as follows:
metadata1.mValue = System.DateTime.Parse("1/1/1999");
metadata2.mValue = System.DateTime.Parse("6/2/2007");
Hope this helps,
Mark