Friday, July 31, 2009

Ambiguity in Javascript Date comparison

The Javascript Date.UTC function helps so convert a date to millisecond.

We use it in our application to do date comparison in relationship review

Syntax :

Date.UTC(yr, mnth, date)

We’d an issue in our application a particular date comparison was not going correctly

The Javascript says 01/31/2010 is greater than 02/02/2010!!

I searched the internet for a solution but in vain later I stumbled upon the fact that for Javascript the month starts with 0, i.e, Jan - 0, Feb – 1 etc

So in our code we said Date.UTC(2010, 01, 31) and it would’ve thought Feb 31st which was not possible. But it gave some millisecond result which became wrong.

I later changed the code accordingly and it works fine!

Saturday, July 11, 2009

SQL to create timeout

"Declare @updateCnt int

set @updateCnt = 0

While(@updateCnt <> 99900000)

begin

set @updateCnt = @updateCnt + 1

end"

IIS crash how to analyze

http://blogs.msdn.com/david.wang/archive/2005/08/29/HOWTO_Understand_and_Diagnose_an_AppPool_Crash.aspx


On Export & Import to SQL Server

I had this situation where I’ve to migrate data in a couple of tables into another database. Both are SQL Server 2005 and I cannot do it now, b’coz the other is production and the operation should happen over a release.

So ideally I’ve to write an insert script but it’s a lil more data (a couple hundreds) which will be very painful to manually write.

I tried to explore the Export and Import option and When I 1st tried export it gave me some product list not supported. Then I installed SP2 which solved the issue.

Then I tried import and it was throwing some validation exception. I tried using Flat file but in vain.

Later I once again tried export with excel this time Edited mapping and I converted the Long text to varchar but note that the varchar has just 255 as a limit in excel. Its ok for me since I dint have long data.

Now I imported and it worked fine but here again I faced a lil issue The Datetime in the excel dint have the precision to milliseconds but its kind of ok b’coz I don’t need that precision for my data.

I later heard that the TFS DataBase edition has a Database compare but it wil work only if the table has a primary key.