|
-
Mar 22nd, 2005, 12:38 PM
#1
Thread Starter
Frenzied Member
Add time and date from two dtp DateTimePickers [RESOLVED]
I have two dtps on a form, one is set up for a date, the other is set up as "HH:mm" for a time. I need to combine the two values into a single string for insertion into a database.
What is the easiest way of doing this?
My problem is that I'm getting the time and date from the second dtp when I only want the time.
Last edited by trisuglow; Mar 23rd, 2005 at 05:27 AM.
This world is not my home. I'm just passing through.
-
Mar 22nd, 2005, 12:50 PM
#2
Re: Add time and date from two dtp DateTimePickers
Use the Format function to format each dtp's value. Then concatinate them together.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 22nd, 2005, 12:58 PM
#3
Lively Member
Re: Add time and date from two dtp DateTimePickers
VB Code:
[FONT=Courier New]
Private Sub Form_Load()
Dim mDate As Date
mDate = CDate(Format(DTPicker1, "dd/mm/yy") & Format(DTPicker2, " hh:mm"))
MsgBox mDate
End Sub[/FONT]
DTPIcker1 has date value and DTPicker2 has time value and in the combination of the both, you will get the result in mDate variable which can be inserted in database.
i love VB more than BV(means wife in our language)
-
Mar 22nd, 2005, 03:31 PM
#4
Re: Add time and date from two dtp DateTimePickers
Another option. Set the Time of the first date picker from the second beforehand.
VB Code:
dtp1.Hour = dtp2.Hour
dtp1.Minute = dtp2.Minute
dtp1.Second = dtp2.Second
msgbox Format$(dtp1.Value,"dd-MMM-yyyy hh:mm:ss")
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
|