Unix Technical Forum

Stored procedure date question

This is a discussion on Stored procedure date question within the SQL Server forums, part of the Microsoft SQL Server category; --> The following is part of my stored procedure where I could use some help: If I remark out the ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 03:46 PM
Charlie
 
Posts: n/a
Default Stored procedure date question

The following is part of my stored procedure where I could use some help:
If I remark out the two lines regarding dates, it runs fine. The date
parameter is passed from a VB app as a text value in the format mm/dd/yy.

Thanks for any help.
Charlie
SELECT * FROM dbo.TWQRHISTEARDOWN_HEADER where

(WQR_TDH_MODELYEAR_T=@Model_Year OR @Model_Year IS NULL)

AND (WQR_TDH_OFFLINEDT_Y>=@Start_Date OR @Start_Date IS NULL)

AND (WQR_TDH_OFFLINEDT_Y<=@Stop_Date OR @Stop_Date IS NULL)


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 03:46 PM
Dan Guzman
 
Posts: n/a
Default Re: Stored procedure date question

You didn't mention the specifics of the problem you are having (i.e. error
message, unexpected results).

> The date parameter is passed from a VB app as a text value in the format
> mm/dd/yy.


I suggest you use neutral DATAFORMAT literal strings ('YYYYMMDD' or
'YYYY-MM-DDTHH:MM:SS'). A better method here is to use parameterized SQL
statements in your VB code so that you don't need to be concerned with
formatting date strings or doubling up quotes in text strings.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Charlie" <jadkins4@yahoo.com> wrote in message
news:476593ee$0$8888$4c368faf@roadrunner.com...
> The following is part of my stored procedure where I could use some help:
> If I remark out the two lines regarding dates, it runs fine. The date
> parameter is passed from a VB app as a text value in the format mm/dd/yy.
>
> Thanks for any help.
> Charlie
> SELECT * FROM dbo.TWQRHISTEARDOWN_HEADER where
>
> (WQR_TDH_MODELYEAR_T=@Model_Year OR @Model_Year IS NULL)
>
> AND (WQR_TDH_OFFLINEDT_Y>=@Start_Date OR @Start_Date IS NULL)
>
> AND (WQR_TDH_OFFLINEDT_Y<=@Stop_Date OR @Stop_Date IS NULL)
>
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:10 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com