1

I am working with data table and using hijri dates when trying to filter dates like so:

 dayDutyTableFilter.DefaultView.RowFilter = "EmployeeID = '" + pRow["PersonID"].ToString() + "' And DayDutyDate >= '" + firstDayMonth
                    + "' And  DayDutyDate <= '" + lastDayMonth + "'";

I got the following error:

Specified time is not supported in this calendar. It should be between 04/30/1900 00:00:00 (Gregorian date) and 11/16/2077 23:59:59 (Gregorian date), inclusive.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
hussein shaib
  • 108
  • 1
  • 9

1 Answers1

0

they are stored in database ,when they are pulled to my application they become hijri because the current thread culture is hijri

No.

A culture has no effect to Calender of a DateTime value. Without any Calender definition in your DateTime constructor, a DateTime is always Gregorian Calender by default.

Looks like your 06/01/1435 12:00:00 value is still in Gregorian Calender which is not between your values.

If you use SQL Server for example, all Date and Time Types save your value with Gregorian Calender.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
  • @husseinshaib My suggestion is; you can convert your Gregorian calender to Hijri Calender and use this `DateTime`. Read http://www.c-sharpcorner.com/UploadFile/M.%20Kaisoun/convert-date-from-solar-gregorian-to-lunar-hijri-using-c153/ and http://stackoverflow.com/questions/11189807/cannot-convert-from-hijri-date-to-gregorian-date-c and http://stackoverflow.com/questions/8601725/hijri-and-gregorian-datetime-constructor and http://stackoverflow.com/questions/19075759/convert-between-calendars – Soner Gönül Jan 22 '15 at 12:15
  • Thx I have come arround this problem and changed the way i was filtering data – hussein shaib Jan 23 '15 at 12:03
  • @husseinshaib Great. Making a standard of when you get values and when you save them is always a good idea. – Soner Gönül Jan 23 '15 at 12:13