Dear all
i have two tables in the table channels three column ( channel_ID - ChannelName - ChannelsStatus) and in the second table SentLog three cloumn (Log_ID - Log_ChannelID - Log_Date) and relationship one to many between
Channels_Channel_ID=SentLog.Log_ChannelID
process is get channelID and do something then add it to SentLog Table in the current datetime
i want to select all channels.Channel_ID that ChannelsStatus=Active and Be older one hour
to specify datetime i use this this c# code to pass datetine in query
DateTime dt=DateTime.Now.AddHour(-1).ToString(@"MM/dd/yyyy HH:mm:ss")
and this is my query
Select Channel_ID From Channels left join SentLog on Channels.Channel_ID=SentLog.Log_ChannelID and Log_Date < cast('12/02/2014 19:34:55 ' AS DATETIME) AND Channels.Channel_Status='Active'
Result : this query give me all channels that active and not active and not specific the date condition
Moved by PIEBALDconsult
channel table have four recorde
channel_ID ChannelName ChannelsStatus
1 r1 Active
2 r2 Active
3 r3 Active
1 r4 DisActive
Sentlog table have 3 records
Log_ID Log_ChannelID Log_Date
1 1 02/12/2014 10:36:11 pm
2 1 02/12/2014 10:37:11 pm
3 1 02/12/2014 10:38:11 pm
and if the current datetime is 02/12/2014 10:38:11 pm
i want to select all channelID that active and be older 1 hour
in this example it must give me channelsid 2,3