Hello,

I have a serious and confusing issues with DateTimePicker.

I have DateTimePicker where user can choose a date and make entry. I then record this entry into the database.

Problem: my application date shows 08-02-2012 (i.e 08 february 2012 in DTPicker value), when i select this and insert it to my database , the MS Access takes this as August, 2 2012, and records it as the same.

I could fix this by using this code:

Dim mydate As DateTime
            mydate = Me.dtpicker10.Value.ToShortDateString
            Dim output1 As String = Format(mydate, "MM-dd-yyy")

and pass sql insert query using

insert into table (mydate) VALUES (#" & output1 & "#)

instead of getting the value directly from the dtpicker. This fix the issues, but when i tried to get the date out of the database to filter it between entry made in certain date, i sometimes have problem

QUESTION:
how do i generalize this for all type of client computers where the date and time settings can be any form.

What will be the best and more flawless ways of approach to target all types of clients?

Am i on the right track?? please advice from your experience

Thanks :)

Edited 4 Years Ago by steplar: n/a

hello!
in you db , date format is same as you specified in your windows , so change the date format .secondly users have concern with the interface , time showing on there datetime picker , there you can set the format property custom and set your required format of date

Regards

hello!
in you db , date format is same as you specified in your windows , so change the date format .secondly users have concern with the interface , time showing on there datetime picker , there you can set the format property custom and set your required format of date

Regards

Try this

Dim date1 As String
        date1 = DateTimePicker1.Value.ToString("MM-dd-yyyy")

while inserting insert only the date1 variable

to get it from database try this

"SELECT * FROM tablename WHERE (Format([Fieldname], 'Short Date'))= '" + DateTimePicker1.Value.Date + "'"

Edited 4 Years Ago by poojavb: n/a

Try this

Dim date1 As String
        date1 = DateTimePicker1.Value.ToString("MM-dd-yyyy")

while inserting insert only the date1 variable

to get it from database try this

"SELECT * FROM tablename WHERE (Format([Fieldname], 'Short Date'))= '" + DateTimePicker1.Value.Date + "'"

thankyou for your reply. I have a bit of a problem though :P

What will be the command to get in between dates? my current code is

SELECT * FROM tablename WHERE orderDate BETWEEN (Format([orderDate], 'Short Date'))= '" + dtpFrom.Value.Date + "' AND (Format([orderDate], 'Short Date'))= '" + dtpTo.Value.Date + "'"

This doesn't seems to work.. any error on my sql?

thankyou for your reply. I have a bit of a problem though :P

What will be the command to get in between dates? my current code is

"SELECT * FROM tablename WHERE orderDate BETWEEN (Format([orderDate], 'Short Date'))= '" + dtpFrom.Value.Date + "' AND (Format([orderDate], 'Short Date'))= '" + dtpTo.Value.Date + "'"

This doesn't seems to work.. any error on my sql?

"SELECT * FROM tablename where (Format([orderDate], 'Short Date'))  between '" + dtpFrom.Value.Date + "' and '" + dtpTo.Value.Date + "'"

Mark thread as solved if it helped u.... :)

Edited 4 Years Ago by poojavb: n/a

This article has been dead for over six months. Start a new discussion instead.