.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

SQL Server throws exception converting today's date based on Arabic(Umm al Qura calendar) to Gregor

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :


My application has support for Arabic and I'm relying on sql server to convert dates from Arabic calendar to Gregorian calendar and vice versa.

The Arabic calendar is based on the lunar sighting and there is a possible difference of 1-2 days.

The country in which my application is deployed uses the Umm Al Qura Arabic calendar(Saudi Arabia, Makkah) and according to it today is 30th of Rabi Al-Thani 1432 A.H. or simply 30/04/1432.

When the query is run to convert today's date (In Arabic) to today's Gregorian Date, SQl Server throws an exception (since SQL server uses the Kuwaiti algo for converting dates).

You can try it out using the following query:

Arabic to Gregorian throws an error (for today's date)

SELECT CONVERT(datetime, '30/04/1432 10:14:41:000AM', 131)

Gregorian to Arabic returns a tomorrow's date

SELECT Convert(nchar, GetDate(), 131)


Is there a work araound for it in SQL Server 2005 Compact Edition?


The .NET compact framework does not support the UmAlQuraCalendar class either,

so this link http://blogs.ms

View Complete Post

More Related Resource Links

Converting SQL Server Date from mm/dd/yyyy to dd/mm/yyyy


I have a form on my website which inserts information into a table stored in sql server 2008... when I try to submit the form and I have entered a date like "08/10/2010" it works perfecting... but when trying to enter "24/10/2010" it doesn't work as the default format in SQL server is "mm/dd/yyyy" - so throws up an error saying:

The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
The statement has been terminated.

Also when I enter the date "08/10/2010" then submit the form, when retreiving that date on another page it displays as "10/08/2010"?!?!?!

Any help is much appreciated :)

SharePoint Portal Server 2003 - email alert based on due date


Hello All,

Hoping someone can help us here.

Note:Workflow/3rd party solutions not an option-

We would like to send an email alert when a list items due date is eqaul to "today".

We are trying to manage some certificates of compliance by flagging the "due date of the particular certificate (list item)" and sending an alert email when that occurs.

Is this feasible in any manner without workflow?

Is it possible to send an alert based on a calculated field when that calculated data changes? .

Any direction would be appreciated.

Thank you

Mike Harvey
Software Solutions Architect


SQL Server 2005 Try and Catch Exception Handling

I'm pretty excited to see that there is some real error handling for T-SQL code in SQL Server 2005. It's pretty painful to have your wonderfully architected .NET solution tainted by less-than-VBScript error handling for stored procedures in the database. The big difference being the addition of TRY..CATCH blocks. Let's take a look:

Essential SQL Server Date, Time and DateTime Functions

The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.

Date/Time Conversions Using SQL Server

There are many instances when dates and times don't show up at your doorstep in the format you'd like it to be, nor does the output of a query fit the needs of the people viewing it. One option is to format the data in the application itself. Another option is to use the built-in functions SQL Server provides to format the date string for you.

SQL Server Date Formats

One of the most frequently asked questions in SQL Server forums is how to format a datetime value or column into a specific date format. Here's a summary of the different date formats that come standard in SQL Server as part of the CONVERT function. Following the standard date formats are some extended date formats that are often asked by SQL Server developers.

dynamically adding sql server columns based on number of files in fileuploader


I want to create a new table to sql database at runtime.  The column names would be "Name", "Date", "Event".  I would also like to have one more column name "Image" but the problem is that since the amount of images will vary, I want the application to count the amount of files in the Multiple fileuploader and then add a image column to the table for the respected amount of files. 

For example if i am uploading 3 files in the multiple fileuploader, the names should be "Name", "Date", "Event", "Image1", "image2", Image3"

I also would like that table name to be name dynamically from the textbox Name when the user enters the information.


I have the following code to make a new table, but I dont know how to name the fields at runtime like previously asked please help!!!


Dim objConn As New SqlConnection("Server=<servername>;uid=<userid>;pwd=<password>;database=master")


userprincipal.changepassword throws exception


Hi all,

      userprincipal.changepassword(oldpassword, newpassword);

gives error: that is Configuration information could not be read from the domain controller, either because the machine is unavailable, or access has been denied. (Exception from HRESULT: 0x80070547)

but userDirectoryEntry.invoke("ChangePassword", new object[] { oldpassword, newpassword });

      userDirectoryEntry.CommitChanges works fine.

Any one please tell me the reason behind this.

WebControls.TableRow throws exception on Add()


I have the following method to strip hidden and user-specified columns from a gridviewrow and return a tablerow. 

    Private Shared Function StripHiddenColumns(ByVal gvRow As GridViewRow, ByVal ColumnsToExclude() As Integer) As TableRow

        Dim row As New TableRow
        Dim i As Integer = 0
            For Each cell As TableCell In gvRow.Cells
                If cell.Visible Then
                    If Not ColumnsToExclude.Contains(i) Then
                    End If
                End If
                i += 1

            Return row
        Catch ex As Exception
            Throw ex
        End Try
    End Function

However, when I run this code and hit the Add method for the TableRow,  I get an InvalidOperationException stating the Collection was modified; enumeration operation may not execute.  I've gotten this exception before, but usually it's because I'm attempting to modify a table that is databound.  This particular one is not, i am creating it.  Can anyone offer any insight? 

Thanks in advance.


Data Points: SQL Server 2005 XML Support, Exception Handling, and More


SQL Server 2005 includes several important improvements to the Transact-SQL (T-SQL) language. One added feature is a new kind of trigger that fires when data definition language (DDL) statements run.

John Papa

MSDN Magazine May 2006

Error Handling: Throwing Custom Exception Types from a Managed COM+ Server Application


Exception handling semantics in .NET are based on type, so you can create custom exceptions that have their own properties and methods. In .NET, exceptions are first-class citizens, and since they're the built-in error handling mechanism, all .NET-compliant languages must support exceptions. In addition, COM+ services are available to .NET code as Enterprise Services, so you can leverage exceptions in your Enterprise Services design.In this article the author describes custom exceptions, throwing exceptions across COM interop boundaries, and working with Enterprise Services.

Bob DeRemer

MSDN Magazine March 2004

dropdownbox which selects records based on criteria (TODAY, THIS WEEK, THIS MONTH, etc)


I have a dropdownbox which I want to use to search records based on a timescale. The gridview populates results based from that search.

So here is how I want to work this;

If a user selects "today" - a list of records input today are populated. If "this week" is selected, a list of all records added within that week from todays date is populated.

I created a forum on this issue previously but to no avail whatsoever. How do I work around this problem?

Help would be much appreciated

change calendar date backColor base on data from db


I want to  change calendar date backColor base on data from db,  I only have vistual 2003 !

on mean time I have

<asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 23px; POSITION: absolute; TOP: 271px"
		    runat="server" Font-Size="XX-Small" Font-Names="Verdana" AutoGenerateColumns="False" Visible="False">
           <asp:BoundColumn DataField="subject" HeaderText="Title"></asp:BoundColumn>
           <asp:BoundColumn DataField="posttimestart" HeaderText="Post date"></asp:BoundColumn>


Sub DayRender(ByVal source As Object, ByVal e As DayRenderEventArgs)
        Dim i As Integer
        For i = 0 To DataGrid1.Items.Count - 1
            If (DataGrid1.Items(i).Cells(1).Text = e.Day.Date) Then
                e.Cell.BackColor = Color.DarkOrange

            End If

    End Sub

when I click the day wich have data in db it change  color , but I want the page load it change color !

Thank you!

Calendar control and date


I have a calendar control , text box and a button . The calendar is invisible in the page load event. When I click on the button,It becomes visible. On selection of a date it becomes the value of the Text Box.
Having said that, my issue is that when this calendar becomes visible, it ruins the arrrangement of the controls on the  page. As I have other controls on the page they  comepletely get displaced. Is there a way to overlap this calendar over the other controls.
I had seen a control that was  some time ago and it was on the client side(probably using javascript or a third party control ) and It wud overlap the other controls and once a value was selected it became invisible.

SPWorkflowManager.CancelWorkflow throws an exception


Sorry, I had posted that same question in the "Dev and Programming" forum, but I'm reposting here because it's more of a workflow related question.

We are trying to cancel workflow programmatically.

It used to work fine until we migrated our environment to a new server and now it fails.

Our code goes something like this: 


foreach (SPWorkflow wf in form.Workflows)


//code omitted for brievety



But an ArgumentException is thrown.

Msdn docs say that an ArgumentNullException exception can be thrown (ArgumentNullException: The workflow to cancel belongs to an SPWeb object that has been deleted) but it is actually an ArgumentException that is thrown. Plus I know for sure that the SPWeb does not get deleted.

I tried to reflector what piec

Submtting Calendar items with variable date information via InfoPath 2007 form



I've seen several posts regarding submitting to a list using and InfoPath form which I am successfully able to do in limited form. (only passing a basic date value) My environment: MOSS 2007 Enterprise w/SP2, InfoPath 2007, SPD 2007.

I'm basically trying to recreate a calendar form with the same data elements (and some additional ones for a specific business requirement) as the standard calendar newform.aspx form. (start time, end time broken down by date, hour, minute and All day event)

I need the form users to be able to select the date and if it is not an All day event...be able to select the hours and minutes just like on the newform.aspx. (date picker control for date and drop downs for hour and minute selection)

On submit I then need to create the list item with the appropriate data passed via a workflow.

My Start Time has a validation rule to not allow dates prior to the current date (and it can't blank) The End Time has a validation rule to not allow dates prior to what is specified as the Start Time value. (Also can't be blank) When I attempt to include conditonal formatting to hide the hour and minute drop downs if 'All Day Event' is selected I get errors stating the fields can't be blank.

I also can't figure out how to pass the entire date/time values or the All Day Event to the list withou

Saving JQuery date back to SQL Server


Hi..my web app uses lots of asp:textboxes and I can save this data back to SQL Server easily using a stored procedure..

however my JQuery datepicker uses an input textbox, how do I save the date entered into this control.

<input id="datepicker"type="text" /> back to server and can I use the same stored procedure that I use for the other data?



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend