This might help you That output is correct. It's telling you that, in order to make testTime equal to now, you'd need to subtract one day from testTime (that's the -1 day), then add back 23 hours, 59 minutes, 59 seconds, and 106000 microseconds. Effectively, that's saying "testTime is 894000 microseconds before now", which is correct; you truncated off the microseconds, makingtestTime ever-so-slightly earlier than now. Are you sure you didn't flip your operands? print(now - testTime) would output 0:00:00.894000 which is probably the output you were looking for.
Hope this helps Why dont you try to create 2 date and check if that date is between them, for example (2010-01-01 >= $date && 2010-01-31 <= $date ). If so, then your in range and all coincidences will appear. If you absolutely have to check for month and year i recommend using functions like YEAR(date) = $yourDate and Month(date) = $yourMonth, this functions should go along with a CUSTOM criteria and could look like:
Hope this helps You will need two separate queries, one for subscriptions and other for unsubscriptions.
SELECT COUNT(*), YEAR(fDateConfirmed), MONTH(fDateConfirmed) FROM tSubscriber GROUP BY YEAR(fDateConfirmed), MONTH(fDateConfirmed)
SELECT COUNT(*), YEAR(fDateUnsubscribed), MONTH(fDateUnsubscribe ) FROM tSubscriber GROUP BY YEAR(fDateUnsubscribed), MONTH(fDateUnsubscribed)
Wanted: DateTime.TryNew(year, month, day) or DateTime.IsValidDate(year, month, day)
seems to work fine There is not a static function IsValidDate() so you have to write it by yourself, first naive implementation may be:
public static bool IsValidDate(int year, int month, int day)
if (year < DateTime.MinValue.Year || year > DateTime.MaxValue.Year)
if (month < 1 || month > 12)
return day > 0 && day <= DateTime.DaysInMonth(year, month);
public static DateTime? TryNew(int year,
if (calendar == null)
calendar = new GregorianCalendar();
if (year < calendar.MinSupportedDateTime.Year)
if (year > calendar.MaxSupportedDateTime.Year)
// Note that even with this check we can't assert this is a valid
// month because one year may be "shared" for two eras moreover here
// we're assuming current era.
if (month < 1 || month > calendar.GetMonthsInYear(year))
if (day <= 0 || day > DateTime.DaysInMonth(year, month))
// Now, probably, date is valid but there may still be issues
// about era and missing days because of calendar changes.
// For all this checks we rely on DateTime implementation.
return new DateTime(year, month, day, calendar);