Re: Date time separation?
I don't see a VB question here. As a SQL question it is almost meaningless without knowing its context. What database for example.
Re: Date time separation?
sorry i forgot to mention access database
with two fields userid datatype string
and timein datatype Date/Time
date and time in table is saved as
989 4/19/2011 2:58:18 PM
990 4/19/2011 3:00:20 PM
now i want to retrieve date like
Code:
txtdate.text=4/19/2011
'and time
txttime.text=3:00 PM
Select * From Checkin where userid=990 And Timein=Dtp1.Value
Dtp1.Value here is the problem
Re: Date time separation?
The date type variable is stored internally as a double
where the date part is the 'integer' portion and the
time part is the fractional portion. Thus:
Code:
Private Sub Form_Load()
Dim d As Date
d = Now
Debug.Print TimeFromDate(d)
Debug.Print DateFromDate(d)
Debug.Print CDbl(d)
End Sub
Private Function DateFromDate(d As Date) As Date
Dim dbl As Double
dbl = CDbl(d)
DateFromDate = CDate(Fix(dbl)) 'get the 'integer' portion
End Function
Private Function TimeFromDate(d As Date) As Date
Dim dbl As Double
dbl = CDbl(d)
TimeFromDate = CDate(dbl - Fix(dbl)) 'get the fractional portion
End Function
Re: Date time separation?
Thanks, you solved my fore coming issue but i am facing query problem
vbcode Code:
Private Sub Cmdok_Click()
ListView2.ListItems.Clear
Set rs = New ADODB.Recordset
With rs
criteria = "Select * from checkinout where userid='" & ListView1.SelectedItem & "' and timein like ' " & DTPicker1.Value & "%'"
.Open criteria, db, 3, 3
Do While Not .EOF
ListView2.ListItems.Add , , !userid
ListView2.ListItems(ListView2.ListItems.Count).SubItems(1) = !timetin
.MoveNext
Loop
End With
Set rs = Nothing
End Sub