ASP & SQL date issues

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default ASP & SQL date issues

    Hi,
    I've got the age old problem of getting a SP in a MSSQL database to see the
    string I'm passing to it as a datetime... I'm getting the ol' error
    converting to datetime from varchar problem.

    I can't see where the issue is:

    The string I'm passing looks like:

    '24/01/2005 00:00:00'
    '23/02/2005 23:59:59'

    All with it's quotes as required..

    THe SP is as follows:

    SELECT dbo.OrderDetails_Retail.ProductID,
    SUM(dbo.OrderDetails_Retail.Quantity) AS RetQtyTotal,
    SUM(dbo.OrderDetails_Retail.UnitPrice) AS RetPriceTotal,
    dbo.Products.ReportColour, dbo.Products.ProductBrand +
    ' - ' + dbo.Products.ProductName AS ProductName
    FROM dbo.Orders_Retail INNER JOIN
    dbo.OrderDetails_Retail ON dbo.Orders_Retail.OrderID =
    dbo.OrderDetails_Retail.OrderID INNER JOIN
    dbo.Products ON dbo.OrderDetails_Retail.ProductID =
    dbo.Products.ProductID
    WHERE (dbo.Orders_Retail.PayStatus <> 'Pending') AND
    (dbo.Orders_Retail.OrderStatus <> N'Deleted') AND
    (dbo.Orders_Retail.OrderDate BETWEEN
    @StartDate AND @ThisDate) AND
    (dbo.Orders_Retail.account = @AccountSession)
    GROUP BY dbo.OrderDetails_Retail.ProductID, dbo.Products.ReportColour,
    dbo.Products.TradeOrder, dbo.Products.ProductName,
    dbo.Products.ProductBrand
    ORDER BY dbo.Products.TradeOrder

    I've tried every different format I can think of but nothing.. I've also
    tried to use the CONVERT and.or CAST functions from within the SQL but
    nothing..

    If I run the SP through access project and paste those exact strings in, it
    works no problem... just when ran through the ASP page it breaks.

    Any ideas?

    James




    Jamesy Guest

  2. Similar Questions and Discussions

    1. JSObject returns wrong date. How can Iextract correct date from digital signature?
      I'm trying to extract name and date from digital signatures by using JSObject in Excel VBA, but JSObject returns wrong date. Year, month, hour and...
    2. #39245 [NEW]: date function generate wrong date with 1162083600 timestamp
      From: lohner at aldea dot hu Operating system: Linux PHP version: 5.1.6 PHP Bug Type: Date/time related Bug description: ...
    3. Live App: Date Issues
      For the life of me I can't figure this out. When I call a function and return the query results to my Flash (AS 1.0) RIA, the date field I am...
    4. asp date issues
      On Sun, 17 Aug 2003 18:10:43 +0000 (UTC), "Jerry Maguire" <jamesbond_422@hotmail.com> wrote: The best way I know of to test for a date when the...
  3. #2

    Default Re: ASP & SQL date issues

    Pass dates in ISO format of YYYY-MM-DD HH:MM

    --
    Jules
    [url]http://www.charon.co.uk/charoncart[/url]
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004


    Julian Roberts Guest

  4. #3

    Default Re: ASP & SQL date issues

    Hi,
    Julian's answer is best but if you don't want to change your code you can
    put as the first line of your SP
    set dateformat dmy

    this will let you enter dates in d/m/y format.

    Jon

    "Jamesy" <NOSPAM@patchworkmedia.co.uk> wrote in message
    news:cvi696$jg6$1@forums.macromedia.com...
    > Hi,
    > I've got the age old problem of getting a SP in a MSSQL database to see
    > the string I'm passing to it as a datetime... I'm getting the ol' error
    > converting to datetime from varchar problem.
    >
    > I can't see where the issue is:
    >
    > The string I'm passing looks like:
    >
    > '24/01/2005 00:00:00'
    > '23/02/2005 23:59:59'
    >
    > All with it's quotes as required..
    >
    > THe SP is as follows:
    >
    > SELECT dbo.OrderDetails_Retail.ProductID,
    > SUM(dbo.OrderDetails_Retail.Quantity) AS RetQtyTotal,
    > SUM(dbo.OrderDetails_Retail.UnitPrice) AS RetPriceTotal,
    > dbo.Products.ReportColour, dbo.Products.ProductBrand
    > + ' - ' + dbo.Products.ProductName AS ProductName
    > FROM dbo.Orders_Retail INNER JOIN
    > dbo.OrderDetails_Retail ON dbo.Orders_Retail.OrderID
    > = dbo.OrderDetails_Retail.OrderID INNER JOIN
    > dbo.Products ON dbo.OrderDetails_Retail.ProductID =
    > dbo.Products.ProductID
    > WHERE (dbo.Orders_Retail.PayStatus <> 'Pending') AND
    > (dbo.Orders_Retail.OrderStatus <> N'Deleted') AND
    > (dbo.Orders_Retail.OrderDate BETWEEN
    > @StartDate AND @ThisDate) AND
    > (dbo.Orders_Retail.account = @AccountSession)
    > GROUP BY dbo.OrderDetails_Retail.ProductID, dbo.Products.ReportColour,
    > dbo.Products.TradeOrder, dbo.Products.ProductName,
    > dbo.Products.ProductBrand
    > ORDER BY dbo.Products.TradeOrder
    >
    > I've tried every different format I can think of but nothing.. I've also
    > tried to use the CONVERT and.or CAST functions from within the SQL but
    > nothing..
    >
    > If I run the SP through access project and paste those exact strings in,
    > it works no problem... just when ran through the ASP page it breaks.
    >
    > Any ideas?
    >
    > James
    >
    >
    >
    >

    Jon Spivey Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139