Red Gate forums :: View topic - Where clause with date type. Need help
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Comparison SDK Previous Versions
SQL Comparison SDK Previous Versions forum

Where clause with date type. Need help

Search in SQL Comparison SDK Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
compvis



Joined: 02 Aug 2010
Posts: 9

PostPosted: Thu Mar 31, 2011 9:56 am    Post subject: Where clause with date type. Need help Reply with quote

hi,

I have a table with a field that has data type is date. So how can i filter data in table by date type, like:

Code:

TableMappings mappings = new TableMappings();
sourcedb.Register(sourcecn, Options.Default);
targetdb.Register(targetcn, Options.Default);
mappings.CreateMappings(sourcedb.Tables, targetdb.Tables);

foreach(TableMapping tbm in mappings)
{
    if (tbm.Obj1.Name == "DQP_T3")
    {
           tbm.Include = true;
           tbm.Where = new RedGate.SQLDataCompare.Engine.WhereClause("Date >= 10/10/2000 && Date <= 10/10/2011");
     }
     else
     {
           tbm.Include = false;
     }
}

Thanks
Back to top
View user's profile Send private message
james.billings



Joined: 16 Jun 2010
Posts: 1123
Location: My desk.

PostPosted: Fri Apr 01, 2011 1:04 pm    Post subject: Reply with quote

That looks reasonable, except as it's a SQL clause, you need to use AND rather than && - for instance:

tbm.Where = new RedGate.SQLDataCompare.Engine.WhereClause("Date >= 10/10/2000 AND Date <= 10/10/2011");

Does that help? Also, to avoid any potential confusion over date formats you may want to specify the dates as yyyy-mm-dd.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group