Handling a date in a datetime format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sc5502
    New Member
    • Jun 2014
    • 102

    Handling a date in a datetime format

    Background: Front End–Visual Studio/Visual Basic 2013: Back End – SQL Server 2014

    I have a vb program that needs to read from a table all entries where the date is a specific value. The table entry has a field that is defined as datetime field. An example of SQL table:

    ID_SignInOut int
    ID_Visitor int
    DateSignIn datetime

    My code (partially complete)-

    Code:
    myCommand = New SqlCommand("Select * from [200-SignInOut] where  ID_Visitor=" &  ID_Visitor & " AND DateSignIn="'" & "???'" , myConnection)
    How do I pullout the just the date?
  • juster21
    New Member
    • Feb 2008
    • 24

    #2
    You would need to surround the date/time with the # sign rather than the '.
    Example: AND DateSignIn=#" & yourDate & "#", myConnection)

    Comment

    Working...