|
-
Nov 11th, 2008, 01:42 AM
#1
Thread Starter
Hyperactive Member
[2008] date issue
hi i am using vb.net 2008 and access
i want the date to b stored in dd/MM/yyyy format
in the main startup prog. i have given this
Code:
Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-GB")
this allows me to enter the date in dd/MM/yyyy format even where the system date is otherwise..
but my prob is if someone types the date 01/04/2008 and is stored by me in the access using the following :
Code:
mCmd = "INSERT INTO RegApplication "
mCmd = mCmd & " (AppDate)"
mCmd = mCmd & " VALUES "
mCmd = mCmd & " (@mAppDate)"
cmd = New OleDbCommand(mCmd, MyConConnection)
cmd.Parameters.AddWithValue("@mAppDate", OleDbType.Date).Value = Format(dtPkAppDate.Value, "dd/MM/yyyy")
even then when the data is displayed it is shown as 04/01/2008..i.e. it takes 01 to b the month and 04 to b the date ...only at places where the system date is not as dd/MM/yyyy but if the system date is dd/MM/yyyy then the date is displayed correctly.
pls. help me out..
thankx
-
Nov 11th, 2008, 03:57 AM
#2
Re: [2008] date issue
You have no idea how many times I've posted this information. Dates are not stored in a database in any format. Dates are stored as binary data, NOT text. They are just a number. Format is only an issue when you DISPLAY a date value, for which you have to convert it to text. FORGET about format when it comes to storing dates. Just assign the binary Date value to your parameter and the date will be stored. Once you get the date back from the database and you want to display it to the user, THAT is when you need to worry about format.
-
Nov 11th, 2008, 08:50 AM
#3
Thread Starter
Hyperactive Member
Re: [2008] date issue
i am binding the data to the dtpicker and it is taking the value straight from the database ....and even then its showing it as 04/01/2008 rather than 01/04/2008
-
Nov 11th, 2008, 09:00 AM
#4
Re: [2008] date issue
Code:
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "dd/MM/yyyy"
these can be set in the form designer.
jmc told you that dates are always stored as a numeric value. how it is displayed is governed by the format.
-
Nov 11th, 2008, 09:03 AM
#5
Thread Starter
Hyperactive Member
Re: [2008] date issue
thankx dbasnett....but i have the format of the datetimepicker as custom which is dd/MM/yyyy
-
Nov 11th, 2008, 11:45 AM
#6
Re: [2008] date issue
 Originally Posted by kuldevbhasin
i am binding the data to the dtpicker and it is taking the value straight from the database ....and even then its showing it as 04/01/2008 rather than 01/04/2008
This is where you specify the format... You should worry about format only when you display it, as JMC have said. What type of control are you displaying the date?
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Nov 11th, 2008, 12:00 PM
#7
Thread Starter
Hyperactive Member
Re: [2008] date issue
hi stanav.
i am binding the date as follows
Code:
mCmd = "Select * From RegApplication ORDER BY Prd_Code & SerialNo"
Dim da_RegApp As New OleDbDataAdapter(mCmd, MyConConnection)
da_RegApp.Fill(ds_RegApp, "RegApplication")
dTable = ds_RegApp.Tables(0)
dtPkAppDate.DataBindings.Add(New Binding("Text", dTable, "AppDate"))
how do i set the format here...?
-
Nov 11th, 2008, 12:52 PM
#8
Re: [2008] date issue
1. Set your DTP.Format to Custom and CustomFormat = "dd/MM/yyyy"
2. Bind the "Value" property of the DTP instead of the "Text"
Code:
dtPkAppDate.DataBindings.Add("Value", dTable, "AppDate")
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Nov 11th, 2008, 01:27 PM
#9
Thread Starter
Hyperactive Member
Re: [2008] date issue
thankx stanav....let me try it out...thankx for helping me
-
Nov 11th, 2008, 06:53 PM
#10
Re: [2008] date issue
Another fine example of how explaining the situation clearly and fully allows a solution to be found. If we don't know the real problem then we can't solve it.
-
Nov 11th, 2008, 06:55 PM
#11
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|