Amazon stores everything as strings in their SimpleDB (strings = simple). Because of this there are some gotchas when it comes to string comparisons.
How to compare dates?
In order to compare dates you need to convert and store the date as an ISO8601 formatted string. An easy solution is to call a function right before you write to SimpleDB. In my case I call a function that takes in a .NET DateTime and converts it to ISO8601.
1: public static String ConvertDateTimeToISO8601(DateTime dt)
2: {
3: return dt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'");
4: }
On the flipside, when you need to read it from SDB, use the ISO8601 to DateTime to bring it back to a C# friendly object, DateTime.
1: public static DateTime ConvertISO8601ToDateTime(String iso)
2: {
3: return DateTime.ParseExact(iso, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", System.Globalization.CultureInfo.InvariantCulture);
4: }
As documented in Amazon’s Tips and Tricks posting, you can also send a ISO8601 formatted query to SDB to pull down a collection of objects matching a date filter. (ie. ['Update Date' > '2008-01-24T22:48:15+01:00'])
Once you, as a developer, get used to converting objects to strings (and vice-versa), working with Amazon SimpleDB becomes much easier.