combining a time and a date to one Date/Time value 
Author Message
 combining a time and a date to one Date/Time value

I have two strings, one with a date (tbDate.text) one with a time
Now I would like to combine both to a new Date.
right now I do this like that:
New Date(DatePart(DateInterval.Year, CDate(tbDate.Text)),
DatePart(DateInterval.Month, CDate(tbDate.Text)), DatePart(DateInterval.Day,
CDate(tbDate.Text)), DatePart(DateInterval.Hour, CDate(tbTime.Text)),
DatePart(DateInterval.Minute, CDate(tbTime.Text)),
DatePart(DateInterval.Second, CDate(tbTime.Text)))

But I think that is kind of to complicated, is their a nicer way to do this?

Thanks Johannes

Sat, 18 Sep 2004 20:13:21 GMT  
 combining a time and a date to one Date/Time value
Maybe just concatenating the two strings (with a space between them) will
work for you.

Dim d As Date = Date.Parse("4/2/02" & " " & "10:42")


Clay Burch
visit for .NET Essentials

Sat, 18 Sep 2004 20:59:29 GMT  
 combining a time and a date to one Date/Time value
Concatenating the strings and using the parse method is easiest as Clay's
response demonstrates.

 Thank You,
 Dale Roberson
 Microsoft Developer Support

 This posting is provided "AS IS" with no warranties, and confers no rights.
 You assume all risk for your use. ? 2001 Microsoft Corporation. All rights

Sun, 19 Sep 2004 03:45:14 GMT  
 [ 3 post ] 

 Relevant Pages 

1. Compare date in form with date/time in form with date/time in database

2. Matching system date/time with field date/time

3. start date/time, end date/time problem

4. How to subtract a date-time from a date-time

5. ADO with Access Date/Time field not storing the time, just the date

6. Converting %date% %time% to VB Time/Date

7. Need function to increase time in date/time field by one hour

8. Null date values in Date/Time fields in Access DB

9. how to set a date time value different from system time in the status bar

10. combining date and time

11. Date/Time to date

12. Extracting the date out of a Date/Time field


Powered by phpBB® Forum Software