Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
stahorse
Yak Posting Veteran
86 Posts |
Posted - 2012-09-06 : 01:29:02
|
| HiI have this code below below and when I try to run run it I get this error:"The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value"please help.DECLARE @StartDate VARCHAR(50), @EndDate VARCHAR(50), @UserId VARCHAR(50)SET @StartDate = '01-07-2001'SET @EndDate = '29-12-2013'SET @UserId = 'jamesm'SELECT [POLICY_ID] , ISNULL(VALUE,0) [VALUE], ISNULL(UNITS,0) [UNITS], TX , CASH_FLOW_SET , PRODUCT_CODE , REC_DATE, [DATE]FROM [Selestia_BI_Staging_Source]..PR_CF_HST CF (NOLOCK)WHERE cf.[REC_DATE] >= @StartDate AND cf.[REC_DATE] <= @EndDate AND cf.Fund_Code = 'FV' |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2012-09-06 : 01:48:12
|
| One option is to change the format to YYYYMMDD . Therefore:DECLARE @StartDate varchar(50), @EndDate varchar(50), @UserId VARCHAR(50)SET @StartDate = '20110701'SET @EndDate = '20131229'SET @UserId = 'jamesm'Jack Vamvas--------------------http://www.sqlserver-dba.com |
 |
|
|
stahorse
Yak Posting Veteran
86 Posts |
Posted - 2012-09-06 : 01:54:23
|
| Thank you that helped. |
 |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2012-09-07 : 01:47:05
|
| OK. That's the standard format I use , unless time is required as well. ideally, the iso 8601 format - would be usedJack Vamvas--------------------http://www.sqlserver-dba.com |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|