|
-
Aug 2nd, 2007, 10:49 PM
#1
Thread Starter
Lively Member
Save the date & time
I am trying to save the date & time into a table in SQL. I am using the datetimepicker control of VB. But, by using this I can save either the date or the time .. not both at a time. How do I store both using a control & in only one column of SQL table.
-
Aug 2nd, 2007, 11:23 PM
#2
Re: Save the date & time
Set the DatePicker Format and CustomFormat properties to allow the user to enter date and time.
Code:
Private Sub Form_Load()
With DTPicker1
.Format = dtpCustom
.CustomFormat = "dd-MMM-yyyy hh:mm:ss"
.Value = Now
End With
End Sub
Private Sub DTPicker1_CloseUp()
Debug.Print DTPicker1.Value
End Sub
As for saving to SQL, are you updating or inserting? Are you using stored procedures, inline sql statements or recordsets???
-
Aug 3rd, 2007, 12:29 AM
#3
Member
Re: Save the date & time
assuming that you are using an update query to perform this
Code:
strDate=Format(dtDate.value,"dd-MMM-yyyy" )
strTime = dttime.value
"update table set datetimecolumn = '"& strDate & " " & strTime &"' where " 'conditions here
OR
you can set the property of the datetime picker control
to opt for
format as 3 -dtpCustom
and change the custom format text as dd-MMM-yyyy hh:mm:ss tt
now you can have the date time in a same control
-
Aug 3rd, 2007, 01:24 AM
#4
Re: Save the date & time
 Originally Posted by pons
assuming that you are using an update query to perform this
Code:
strDate=Format(dtDate.value,"dd-MMM-yyyy" )
strTime = dttime.value
"update table set datetimecolumn = '"& strDate & " " & strTime &"' where " 'conditions here
OR
you can set the property of the datetime picker control
to opt for
format as 3 -dtpCustom
and change the custom format text as dd-MMM-yyyy hh:mm:ss tt
now you can have the date time in a same control
The query would depend on the database, and the data type of destination field.
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
|