hi friends,
i have two datetimepickers in a window form application.One datetimepicker is used to select date and second one is for time.
Now i want to combine date from DTP1 and time from DTP2 and update the database with the selected combined datetime value using vb.net.
Thankyou

Recommended Answers

All 12 Replies

what you mean about combine?

  TextBox1.Text = DateTimePicker3.Value + " " + DateTimePicker4.Value

Note - DateTimepicker3 has date and Datetimepicker4 has time in it....the value will be displayed in textbox4...and the datetimepicker values are separated by a space

check if u needed the same....

Do you need help with the database update as well? The answer would depend on whether you need help with the query itself or the connectivity. And the answer may depend on what type of database you are using and how you are storing the date/time value.

Hi
if you want to concatinate two values as a single string, then you're half way there. next step is in the Database to configure the field to be a char or varchar field ( or equivalent depending on Database) and simply pass textbox1.Text in as a string.

Not necessary. The field can be defined as datetime and updated as

set [fieldname] = '2012-04-19 23:17:01'

composing the above partial query from the previously concatenated values. Datetime fields can then be properly manipulated using SQL datetime functions.

TextBox1.Text = DateTimePicker3.Value + " " + DateTimePicker4.Value

thts fine....but how to convert textbox value to valid datetime format and update in database.....i m using sqlserver 2008r2 and vb.net.

thts fine....but how to convert textbox value to valid datetime format and update in database.....i m using sqlserver 2008r2 and vb.net.

i think Reverend Jim was answered it.

Sorry I thought you wanted to join the two values in a separate string i.e. "03/05/2012 04/05/2012" this is not a date value, I've reread and realised what your up to - Reverend Jim is quite correct...

why would you combine two datetimes?
Can you explain this better?

They want to put the date value from one with the Time value of the other i.e.

04/05/2012 12:08
03/05/2012 15:30

= 04/05/2012 15:30

As for why? Why not?

hey friends,
DTP1 has short date(no time) only and DTP2 has time format only (no date) so that when both are combined i get a valid date & time.
hope u got it this time.

So I had answered above....did it help you...
Click Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.