Results 1 to 6 of 6

Thread: Dates in SQL Server

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186

    Post

    Hello there:
    I'm new in working with SQL Server from VB, and I'm having a problem I suppose is simple:
    I've written a Stored procedure in wich the parameters are a start date and an end date.
    In VB I dim these variables as Date and the input is taken from DTPicker controls.
    The thig is that somehow I never get the desired records, and I don't get errors either?!?!

    I've tried to run it from SQL Server and it works, with the dates being in any format.
    But from VB I get zero in return.

    Please help
    Thanx
    André

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Location
    Oporto, Portugal
    Posts
    134

    Post

    How are you declaring variables in VB.
    Try giving the variables a Variant data type.

    ------------------
    Jorge Ledo
    [email protected]
    Portugal

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Try passing your date as "#" & MyDateVariable & "#"

    HTH

    Tom

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    SQL Server expects the dates in a certain format, enclosed in quotes. The "#" delimiter works with Access but not SQL Server.

    Post your Stored Procedure, and how you're calling it in VB, and we'll have a look.

  5. #5
    Lively Member
    Join Date
    Apr 1999
    Location
    India
    Posts
    73

    Post

    hi
    I have faced a similar problem in my project. this is what I did, I fetch the data from ant control read that data in a variable...and pass that data into a mm/dd/yy format to sql server it works and always gives u the desired results. I declared the variables as string on both the ends at sql server as well as date. what I have analyzed is that u might be setting dtpicker in a specific format which might be diff from the format in which sql server want the date...it might increase the codes but it will give u the desired results in every format.
    bcz if your application if going to wrk on diff locations u might face prob when user sets the date in diff fromat for their local system.
    feel free to ask if u need any more.
    Thanx Manish

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186

    Post

    Thanx guys for your help, I got it working now, it had something to d owith the output parameter, once I didn't have an output parameter the recordset got back as wished!!
    Thanks
    André

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width