Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.

  1. #1

    Default Date comparisons

    Hi. I'm using ADO.NET to retrieve data from SQL Server via stored
    procedures. Lately I found the following problem:

    There's a stored procedure that has a DateTime input parameter (say
    @statusDate). This parameter is passed from ADO.NET code as DateTime.
    Inside stored procedure, there's a comparison of dates that looks like
    "...WHERE createDate = @statusDate". Here, "createDate" is a column of
    datetime type. The application was deployed on number of different
    servers and worked just fine. Except one specific server where this
    comparison fails, although the dates seem equal. I suspect that this
    might have something to do with Locale/Regional Settings, although I
    don't really see how they can impact in this case. Maybe someone can
    give me a hint. Thanks.
    --
    Direct access to this group with [url]http://web2news.com[/url]
    [url]http://web2news.com/?microsoft.public.sqlserver.programming[/url]
    melo Guest

  2. Similar Questions and Discussions

    1. Date comparisons using UNIX timestamp?
      Hi all, How does one compare dates if one (or both) of the dates is before 1/1/1970? I tried converting the user's input (from selection boxes;...
    2. comparisons and depth
      sorry to post two questions in one day, but i have run into a second problem. i have a looping movie clip which changes _y position randomly with...
    3. Camera Comparisons link?
      Rob Wild wrote: www.photozone.de is pretty good.
    4. chaining comparisons
      When I learned python I was overjoyed that I could evaluate 1 < 2 < 3 and get "true". I just realized that you can't do that in Ruby. Is there a...
    5. NASA G5 v PC speed comparisons
      It seems NASA thinks that G5s are pretty fast, and they're independant http://www.macobserver.com/article/2003/07/04.7.shtml PK
  3. #2

    Default Re: Date comparisons

    I think you guessed it right. This must be problem with the server's
    language settings. By default SQL server can understand format yyyymmdd.
    hence while passing value make sure @statusdate variable's value matches
    that format.

    --
    -Vishal
    "melo" <melo.news.invalid@web2news.net> wrote in message
    news:49099N829@web2news.com...
    > Hi. I'm using ADO.NET to retrieve data from SQL Server via stored
    > procedures. Lately I found the following problem:
    >
    > There's a stored procedure that has a DateTime input parameter (say
    > @statusDate). This parameter is passed from ADO.NET code as DateTime.
    > Inside stored procedure, there's a comparison of dates that looks like
    > "...WHERE createDate = @statusDate". Here, "createDate" is a column of
    > datetime type. The application was deployed on number of different
    > servers and worked just fine. Except one specific server where this
    > comparison fails, although the dates seem equal. I suspect that this
    > might have something to do with Locale/Regional Settings, although I
    > don't really see how they can impact in this case. Maybe someone can
    > give me a hint. Thanks.
    > --
    > Direct access to this group with [url]http://web2news.com[/url]
    > [url]http://web2news.com/?microsoft.public.sqlserver.programming[/url]

    Vishal Parkar Guest

  4. #3

    Default Re: Date comparisons

    I suggest that you run a profiler trace and compare a working with the non-working SQL Server.
    My guess is that the client application passes the date in a format which depends on regional
    setting instead of a "safe" format.

    --
    Tibor Karaszi, SQL Server MVP
    Archive at: [url]http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver[/url]


    "melo" <melo.news.invalid@web2news.net> wrote in message news:49099N829@web2news.com...
    > Hi. I'm using ADO.NET to retrieve data from SQL Server via stored
    > procedures. Lately I found the following problem:
    >
    > There's a stored procedure that has a DateTime input parameter (say
    > @statusDate). This parameter is passed from ADO.NET code as DateTime.
    > Inside stored procedure, there's a comparison of dates that looks like
    > "...WHERE createDate = @statusDate". Here, "createDate" is a column of
    > datetime type. The application was deployed on number of different
    > servers and worked just fine. Except one specific server where this
    > comparison fails, although the dates seem equal. I suspect that this
    > might have something to do with Locale/Regional Settings, although I
    > don't really see how they can impact in this case. Maybe someone can
    > give me a hint. Thanks.
    > --
    > Direct access to this group with [url]http://web2news.com[/url]
    > [url]http://web2news.com/?microsoft.public.sqlserver.programming[/url]

    Tibor Karaszi Guest

  5. #4

    Default Re: Date comparisons

    The date conversion "failure" could be in the .Net code since within SQL
    Server a date is a date is a double.

    If the date settings in the control panel are (EG) d/m/y on the troublesome
    machine, but m/d/y on all others this could happen when converting Text in
    the UI to Date prior to putting it into the parameter value.

    Using Profiler will help as then you will be able to see the parameter
    values passed into SQL Server.

    - Tim


    "melo" <melo.news.invalid@web2news.net> wrote in message
    news:49099N829@web2news.com...
    > Hi. I'm using ADO.NET to retrieve data from SQL Server via stored
    > procedures. Lately I found the following problem:
    >
    > There's a stored procedure that has a DateTime input parameter (say
    > @statusDate). This parameter is passed from ADO.NET code as DateTime.
    > Inside stored procedure, there's a comparison of dates that looks like
    > "...WHERE createDate = @statusDate". Here, "createDate" is a column of
    > datetime type. The application was deployed on number of different
    > servers and worked just fine. Except one specific server where this
    > comparison fails, although the dates seem equal. I suspect that this
    > might have something to do with Locale/Regional Settings, although I
    > don't really see how they can impact in this case. Maybe someone can
    > give me a hint. Thanks.
    > --
    > Direct access to this group with [url]http://web2news.com[/url]
    > [url]http://web2news.com/?microsoft.public.sqlserver.programming[/url]

    Tim 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