|
How do I compare dates in ms sql tables in C#? -- rhaazy --
Using ms sql 2000 and VS2003 I need a little addition to my application that already gets a bunch of records from a database. Each row has two dates from two different tables, and an ID column so the return set looks like this: ID DateLastModified DateLastSent 1 12/12/05 time 12/15/05 2 9/8/06 9/1/06 What I need to do is compare the two dates in any row and be able to have an event fire if and only if the date in the DateLastSent column is smaller (occured before) the date in DateLastModified. I think I could get as far as getting the two dates but I have no idea how to compare the datetimes in C#. My other problem is that I'm not sure how I would be able to check every row and select the ID of those that meet my condition. Any help would be appreciated. Thanks in advance. |
|
-- rhaazy --
No, you guys got it perfect, after posting I realized all I had to do was add that where clause at the end to only get the dates I need. Don't know what I was thinking. Here is my new problem however, I have a windows service running on the server, after I get the IDs that meet my condition from above I want to send those IDs to the service so that It knows which profiles need to be updated(by update I mean creating an XML file to replace the profile stored locally on the client). I can create the XML file but am stumped on trying to figure out how to let the service know how to create an XML file for each ID that came back. |
|
-- BradleyPeter --
My solution would be to forget about the service itself doing it. What you need, I think, is a Server activated object hosted by the service. The SAO would have a method that took the list of ids as a parameter and then iterated over the list of ids, creating the appropriate XML file for each iteration. It can either pass the XML back as the return value (maybe a FileStream, or a very long string), or store it on the server file system somewhere. HTH Peter -----Original Message----- From: DotNetDevelopment on behalf of rhaazy Sent: Mon 7/24/2006 9:51 PM To: DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting Cc: Subject: Re: How do I compare dates in ms sql tables in C#? No, you guys got it perfect, after posting I realized all I had to do was add that where clause at the end to only get the dates I need. Don't know what I was thinking. Here is my new problem however, I have a windows service running on the server, after I get the IDs that meet my condition from above I want to send those IDs to the service so that It knows which profiles need to be updated(by update I mean creating an XML file to replace the profile stored locally on the client). I can create the XML file but am stumped on trying to figure out how to let the service know how to create an XML file for each ID that came back. |