x

Convert Gregorian date to Julian date and use dateadd

I have a date field that is a decimal data type which I converted to datetime. When I use dateadd with the converted data type in SSMS 2005 it works but when I put this in SSRS 2008 I get the following error.

 dateadd(dd, cast(right(lm.jha_dw_loaddate ,3) as varchar(3)) -1,
                    cast(left(lm.jha_dw_loaddate, 4) as datetime)) = @BeginDate + 7


Error Message: Conversion failed when converting the nvarchar value '4/10/2012 12:00:00 AM' to data type int

This works fine in SSRS 2008.

 dateadd(dd, cast(right(lm.jha_dw_loaddate ,3) as varchar(3))-1,  
                    cast(left(lm.jha_dw_loaddate, 4) as datetime)) = @BeginDate

Any suggestions?

more ▼

asked May 03, 2012 at 04:46 PM in Default

avatar image

scarney
0 2 2 2

Your 2 queries are different. Your 2005 script has + 7.

May 04, 2012 at 06:08 AM sp_lock

SSMS vs SSRS ? Where are you putting this in SSRS?

May 04, 2012 at 07:27 AM Kev Riley ♦♦

I copied the wrong query, both should be the first one. Where I'm having the problem is when I try to add days (+7). The query works fine in SSRS when I don't try to add days.

Thanks.

May 06, 2012 at 04:15 PM scarney
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Instead of @BeginDate + 7, try DATEADD(dd,7,@BeginDate)

more ▼

answered May 04, 2012 at 10:58 AM

avatar image

Grant Fritchey ♦♦
137k 20 42 81

Thanks, I wll give that a try.,

May 06, 2012 at 04:15 PM scarney
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x86

asked: May 03, 2012 at 04:46 PM

Seen: 1876 times

Last Updated: May 07, 2012 at 10:07 AM

Copyright 2016 Redgate Software. Privacy Policy