Dates misinterprets with date formats in control panel  
Author Message
Mohanraj_k





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

HI,

How to control the date format in the control panel. regional settings.

because when we change the formats in the control panel while the application is running. the date values stores different values.

How to prevent this by locking the control panel settings.

Or to change the values of the date format in the regional settings programmatically. when we start out application.

Is this the right syntax for storing dates

anydatatable("anydatefield")= cdate(format(dtpicker1.value,"dd/MM/yyyy")).

or simply anydatatable("anydatefield") = dtpicker1.value

Although set the custom format in the properties, it changes according to the regional settings.

How to access the .cpl classes. to work programmatically.

Thanks in advance

Mohan Raj K.




Visual Basic13  
 
 
nobugz





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

Make sure the column type of the database table is datetime, not varchar.


 
 
Mohanraj_k





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

It is actually a typed dataset.

 
 
nobugz





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

As long as the table column type is datetime, your dataset member will be of type System.DateTime. Which makes it independent of the culture or regional format override. If the table column type is varchar, the dataset member will be of type String. Which will buy you a lot of trouble someday...


 
 
Mohanraj_k





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

NO., it is actually Date datatype only. of oracle database 10g.

Not only changing. when the date format is set to dd/MM/yyyy in custom format. if, in regional settings M/d/yy. it takes as the value - 07 - jun to 06-July (07/06...to 06/07.  and this happens to only if dates are between 1..12.)

 



 
 
nobugz





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

Oh, Oracle. Hmm, what provider do you use Note that MSFT has a dedicated Oracle class library for .NET. Here's an article that describes it.


 
 
Mohanraj_k





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

Thanks for your replies.

I used Oracle Developer Tools for Visual Studio 2005. ( that recently launched.)

created connection,dataadapters,connection with oracle.dataaccess.client.

and created typed dataset using the system.data.OracleClient.

will there by any problems.



 
 
Mohanraj_k





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

Hi, No,

Still I getting error with date formats specified in the control panel affects the date fields entered.

actually I am using this for safe, but still i get error. Always use datetimepicker control

to store value I use,like,

dt.rows(0).LOTDATE= cdate(format(dtpicker1.value,"dd/MM/yyyy"))

'-- No Problem If, I have same date format in the control panel,if other than this like M/d/yyyy, then values automatically misinterepreted like 07/06/2007 to 06/07/2007.

for retrieving also the same problem.

Please Reply.

'-- updated --

Hi, Tried also changing the DateTimeMode property in the dataset to UTC. but problem exists.



 
 
Mohanraj_k





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

Hi,

It's a request to Forum Members, to please validate the changed date values with the control panel regional settings(esp.INDIAN Settings dd/MM/yyyy), if time permits to you people.

So that it can be clarified.

Thanks in advance for any Efforts.

Mohan Raj k.



 
 
pyeung





PostPosted: Visual Basic General, Dates misinterprets with date formats in control panel Top

Use this function:

Code Block

Function String2Date(ByVal DDMMYY As String) As DateTime
Return DateTime.Parse(DDMMYY, New System.Globalization.CultureInfo("en-GB"))
End Function

Many people have problem with Date in programming. For some other date related issues, please visit my blog here:

http://petersgyoung.spaces.live.com/ _c11_BlogPart_pagedir=Next&_c11_BlogPart_handle=cns!706591A544AC0876!139&_c11_BlogPart_BlogPart=blogview&_c=BlogPart