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.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Date Field not showing correct Date

Author  Topic 

tech2
Yak Posting Veteran

51 Posts

Posted - 2013-03-29 : 08:33:12
SSRS Report Builder 3.0 2008 R2

My query results is showing the current date, not the date in my date field 'StatusDate'

I also created a calculated field named 'CurrentDate' and trying to get my 'datediff' column 'StatusDays' to calculate the correct days.

Any help would highly be appreciated.

=DateDiff("d",Format(Fields!StatusDate.Value,"Short Date"),Format(Fields!CurrentDate.Value,"Short Date"))

Thanks,

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-29 : 13:42:53
id StatusDate is of type datetime, you need just this
=DateDiff("d",Fields!StatusDate.Value,Now())


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tech2
Yak Posting Veteran

51 Posts

Posted - 2013-03-29 : 15:42:09
Thanks for the response; After using your expression below; The dates in the 'statusdate' field are still coming back as the current date.

I'm sure your expression works but there is something that has to be included in the formula that will keep the dates from changing.

thanks,

quote:
Originally posted by visakh16

id StatusDate is of type datetime, you need just this
=DateDiff("d",Fields!StatusDate.Value,Now())


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-29 : 21:46:29
that sounds like the issue is more with the query used to populate the dataset rather than the usage of datediff.

Examine your query that retrieves the data. If the query is selecting from a table, see what is in the table in the column that is being selected. If it is not, see how StatusDate is being computed.
Go to Top of Page

tech2
Yak Posting Veteran

51 Posts

Posted - 2013-03-30 : 10:38:54
Yes, that's correct, the query result set is not bringing back the correct dates from the datasource. It's a simple select query that includes the 'StatusDate' field, with different dates, no computing is being executed. Does the field have to go through a date conversion like the example below? I tried this, but it didn't work.

CONVERT(VARCHAR(10), STATUSDATE, 101) as STATUSDATE

Thanks,

quote:
Originally posted by James K

that sounds like the issue is more with the query used to populate the dataset rather than the usage of datediff.

Examine your query that retrieves the data. If the query is selecting from a table, see what is in the table in the column that is being selected. If it is not, see how StatusDate is being computed.

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-30 : 13:07:02
nope. No need of conversion if its a straight pull. Perhaps you could post query part which retrieves the date for us to see what issue is.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -