dbTalk Databases Forums  

Stored procedure date question

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Stored procedure date question in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Charlie
 
Posts: n/a

Default Stored procedure date question - 12-16-2007 , 03:09 PM






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)



Reply With Quote
  #2  
Old   
Dan Guzman
 
Posts: n/a

Default Re: Stored procedure date question - 12-17-2007 , 06:40 AM






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

Quote:
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 (AT) yahoo (DOT) com> wrote

Quote:
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)




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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.