Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Displaying dates in Name and dd-mm-yyyy


Displaying dates in Name and dd-mm-yyyy

Author
Message
jaype-365633
jaype-365633
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 111
Hi All, I need a help on displaying dates in Name and dd-mm-yyyy on the particular month, when there is no data on the date, the dates are not coming in reports. attached the screen shot of what i am getting from RS and what i am expecting, please give me your valuable advice on how to get the information.

Thanks
Jprakash
Attachments
SQL.jpg (28 views, 97.00 KB)
wschampheleer
wschampheleer
SSC Eights!
SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)

Group: General Forum Members
Points: 870 Visits: 303
For converting the number to a date, you can use the DateSerial function:

Description
Returns a Date value representing a specified year, month, and day, with the time information set to midnight (00:00:00).

Examples
=DateSerial(DatePart("yyyy",Fields!BirthDate.Value)-10, DatePart("m",Fields!BirthDate.Value)+3,DatePart("d",Fields!BirthDate.Value)-1)
=DateSerial(DatePart(DateInterval.Year,Fields!BirthDate.Value)-10,DatePart("m",Fields!BirthDate.Value)+3,DatePart("d",Fields!BirthDate.Value)-1)
=DateSerial(2007,10,24)

To get the name of the day, use the following Expression

=weekdayname(weekday(now()))

where you replace now() with your date(time) field.

Regards,

Willem
http://wschampheleer.wordpress.com
jaype-365633
jaype-365633
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 111
Hi Willem,
the query i have used in sql is
SELECT DATEPART(YY, CHECKINTIME) AS Year, DATEPART(MM, CHECKINTIME) AS
Month, DATEPART(D, CHECKINTIME) AS 'Date', SUM(UPLOADLNCNT)
AS 'Total Lines', TRUSTID
FROM DEPTABLE
GROUP BY DATEPART(yy, CHECKINTIME), DATEPART(M, CHECKINTIME), DATEPART(D,
CHECKINTIME), TRUSTID
ORDER BY Year DESC, Month DESC, 'Date' DESC
and i tried the examples, but still i am getting error.
Please help me on this
wschampheleer
wschampheleer
SSC Eights!
SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)

Group: General Forum Members
Points: 870 Visits: 303
There's a few things to be said about your query but syntactically it is correct.
Where are you getting an error and what does it say?

Regards,

Willem
http://wschampheleer.wordpress.com
jaype-365633
jaype-365633
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 111
Hi Willem, attached the screenshot
The error i am getting is in reports as #Error in the day number which was displaying earlier, and in reports on expression i have used
=DateSerial(DatePart("YYYY",Fields!Year.Value)-10, DatePart("m",Fields!Month.Value)+3,DatePart("d",Fields!Date.Value)-1)
Attachments
Error.JPG (8 views, 26.00 KB)
wwei
wwei
Valued Member
Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)Valued Member (59 reputation)

Group: General Forum Members
Points: 59 Visits: 452
If try something simple, it might make things easier and less errors,

If you could return the CHECKINTIME, just go the the Text Box Properties, in the Number/Custom section, using Custom Format:
dddd, will show name of weekday, like Monday, Tuesday...
d-MMM-yyyy, will show format of 0-Jan-2010...
wschampheleer
wschampheleer
SSC Eights!
SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)

Group: General Forum Members
Points: 870 Visits: 303
Why are you still using datepart when you have already done the extraction in your query?

Try this:

=DateSerial(Fields!Year.Value-10, Fields!Month.Value+3,Fields!Date.Value-1)

Regards,

Willem
http://wschampheleer.wordpress.com
jaype-365633
jaype-365633
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 111
Hi Willem, thanks its working fine now, i have used
=DateSerial(Fields!Year.Value-10, Fields!Month.Value+3,Fields!Date.Value-1) in Expression on that column and in same column text box properties > Number > in category i chose date and in type 31-Jan-2000, but now only thing is i am not getting all the dates of the month january, coz there are no data's in 1st,2nd and 3rd date, i need to display whole of jan month with date's and in the data column as 0.
do i need to change the query, if yes, can you please help on the query

Thanks,
Jprakash
wschampheleer
wschampheleer
SSC Eights!
SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)SSC Eights! (870 reputation)

Group: General Forum Members
Points: 870 Visits: 303
You need to do an outer join with a table that contains all dates on which you want to report.

Check this topic for some inspiration.

Regards,

Willem
http://wschampheleer.wordpress.com
jaype-365633
jaype-365633
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 111
Hi Willem, i tried on this query
select x.TRUSTID,Y.Date1, isnull(x.total,0) from
(select TRUSTID, Date=convert(varchar(25),UPLOADTIME,103),
Total=SUM(uploadlncnt) from DCLIVEJOBS where UPLOADTIME between '2010-01-01' and '2010-01-31'
group by TRUSTID,UPLOADTIME
)X
right outer join
(select '' as TA_A_NAme,convert(varchar(25),DATE,103) as date1,0 as Total from dbo.F_TABLE_DATE('01-Jan-2010','31-Jan-2010')
)Y on Y.Date1=X.Date order by Y.Date1

but i am getting 0 below the date column with a new row added (attached the screenshot), and more over i need to add a new row below the date date row and display the date as 31-Jan-2000
Attachments
DATE.JPG (9 views, 10.00 KB)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search