getting incorrect information

Posted by kishoreknl2007-10932 under Others on 9/8/2012 | Points: 10 | Views : 912 | Status : [Member] | Replies : 2
hi frnds i am trying to retrive the data in between two dates but its not getting the correct information...

here i took access database and i took the field datatype as date/time and i setted the datatype format as dd/MM/yyyy and in the visual studio also i took a datetime picker for selecting the date which is in the format of dd/MM/yyyy. it is storing in the correct format only but while retriving it is not getting the information correctly. for example....

select * from servicebills where [BillDate] between #05/10/2012 12:00:00 AM# and #05/10/2012 12:00:00 AM#


but the actual format of the date is 10/05/2012...

is there any other options for changing the date format of datetimepicker in vs studio...

Thanks & Regards
From:
Sai Kishore
kishoreknl.2007@gmail.com



Responses

Posted by: Ranjeet_8 on: 9/8/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Try this,

string UrDateString = "22/09/2012"; // DD/MM/YYYY
System.Globalization.DateTimeFormatInfo DT = new System.Globalization.DateTimeFormatInfo();
DT.ShortDatePattern = "dd/MM/yyyy";
DateTime validDate = Convert.ToDateTime(UrDateString, DT);


OUT WILL BE :
09/22/2012 // MM/DD/YYYY

kishoreknl2007-10932, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vasanthmvp on: 9/8/2012 [Member] Starter | Points: 25

Up
0
Down
Hi, here is a question in the forum similar to this.
Visit these, if not cleared.. let me know.

DateTime StartDate1 = DateTime.ParseExact(tbStartdate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);

http://www.dotnetfunda.com/forums/thread11405-how-to-update-a-record-or-value-in-sqlserver-2005-using-aspnet.aspx

Regards,

Awesome Coding !! :)

kishoreknl2007-10932, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response