Date function not working in server 2008

Posted by Shoyebaziz123 under ASP.NET on 10/9/2012 | Points: 10 | Views : 818 | Status : [Member] | Replies : 0
Hi All,

i am using this format to get date in dd/MM/yyyy format

string str=DateTime.Now.ToString("dd/MM/yyyy");

output 09/10/2012

its working all of operating system correctly , but when i am using server 2008 (OS) it returns
09-10-2012

then i am using a function to convert this date into m/d/y format ( for sql operation)

public static DateTime ConvertDate(string mDate)
{

string sDate = mDate.Replace("-", "/");
sDate = sDate.Replace(".", "/");
string[] dtparts = sDate.Split('/');
DateTime tDate = new DateTime
(Convert.ToInt32(dtparts[2]),
Convert.ToInt32(dtparts[1]),
Convert.ToInt32(dtparts[0]));

return tDate;
}
works fine for all OS , but not for server 2008
its making sql server not working properly while i am using DML operation,
i have also change the Region And Culture setting of Server 2008 in various format but there is an error ' Index was outside bound of array'

now what i have to do ?

Thanks




Responses

(No response found.)

Login to post response