stored proc with datetime

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mcnewsxp

    stored proc with datetime

    i need a little syntax help with a SP.
    i have a datetime field that is part of the search criteria.
    it may be null in which case it should be ingnored or get all dates.
    if a date parameter is passed it should find it.

    it only works for all when the arrivaldate is a varchar.
    @varArrivalDate varechar(10) = '%',

    and only finds the matching date when
    @varArrivalDate smalldatetime,

    ?
  • Plamen Ratchev

    #2
    Re: stored proc with datetime

    Please do not multipost. Replied in .programming, copy/paste here:

    You should use a DATETIME parameter and then write your WHERE conditions
    like this:

    WHERE arrival_date = @ArrivalDate
    OR @ArrivalDate IS NULL;

    HTH,

    Plamen Ratchev

    Comment

    • mcnewsxp

      #3
      Re: stored proc with datetime

      On Jun 19, 3:25 pm, "Plamen Ratchev" <Pla...@SQLStud io.comwrote:
      Please do not multipost. Replied in .programming, copy/paste here:
      >
      You should use a DATETIME parameter and then write your WHERE conditions
      like this:
      >
      WHERE arrival_date = @ArrivalDate
      OR @ArrivalDate IS NULL;
      >
      HTH,
      >
      Plamen Ratchevhttp://www.SQLStudio.c om
      thanks for not yelling about the multi-posting.

      Comment

      Working...