Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server Newbies
»
Date Format in SSRS
11 posts, Page 1 of 2
1
2
»»
Date Format in SSRS
Rate Topic
Display Mode
Topic Options
Author
Message
deepeshdhake
deepeshdhake
Posted Tuesday, October 02, 2012 5:53 PM
SSC Rookie
Group: General Forum Members
Last Login: Wednesday, April 10, 2013 4:08 PM
Points: 32,
Visits: 134
I have the date time field. I want extract only Month and the year. How can I do the same.
Current format of the field is "10/01/2012 hh:mm:ss"
Need to convert to "October 2012"
I want to do these changes in SSRS.
Post #1367349
robert.gerald.taylor
robert.gerald.taylor
Posted Tuesday, October 02, 2012 6:19 PM
Right there with Babe
Group: General Forum Members
Last Login: Yesterday @ 7:49 AM
Points: 739,
Visits: 783
deepeshdhake (10/2/2012)
I have the date time field. I want extract only Month and the year. How can I do the same.
Current format of the field is "10/01/2012 hh:mm:ss"
Need to convert to "October 2012"
I want to do these changes in SSRS.
Assuming your source data field is a datetime datatype and you don't want the day, you could do something like:
=Format(Fields!YourDate.Value, "MMMM") & " " & CStr(Year(Fields!YourDate.Value))
HTH,
Rob
*I don't have SSRS open as I type this, so please double check my memory to make sure it works as you wish
Post #1367355
deepeshdhake
deepeshdhake
Posted Tuesday, October 02, 2012 8:16 PM
SSC Rookie
Group: General Forum Members
Last Login: Wednesday, April 10, 2013 4:08 PM
Points: 32,
Visits: 134
Hello Rob,
Few data is correct and few is wrong. Here is the sample output I am getting:
Octaber 12
Jul12 12
SetpAmer
What is the problem?
Post #1367379
robert.gerald.taylor
robert.gerald.taylor
Posted Tuesday, October 02, 2012 10:00 PM
Right there with Babe
Group: General Forum Members
Last Login: Yesterday @ 7:49 AM
Points: 739,
Visits: 783
Impossible to know without seeing the data, but I'd guess that the field isn't a datetime datatype, but rather a varchar() where not all of the values are correctly formatted dates.
Take a look at the raw data coming through for that field.
Post #1367388
deepeshdhake
deepeshdhake
Posted Tuesday, October 02, 2012 10:57 PM
SSC Rookie
Group: General Forum Members
Last Login: Wednesday, April 10, 2013 4:08 PM
Points: 32,
Visits: 134
Hello,
Originally, that column has Date as Data type. So, now what to do? IS there any other procedure to do this?
Post #1367401
anthony.green
anthony.green
Posted Wednesday, October 03, 2012 2:12 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
=FORMAT(Field!DateField.Value "MMMM yy")
How about the above?
Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1
&
Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger
Post #1367457
deepeshdhake
deepeshdhake
Posted Wednesday, October 03, 2012 10:11 AM
SSC Rookie
Group: General Forum Members
Last Login: Wednesday, April 10, 2013 4:08 PM
Points: 32,
Visits: 134
This too doesn't work. Is there any other way to do this.
With Format(), I am getting some thing like this:
OctAber
SetAmber
etc
Post #1367831
robert.gerald.taylor
robert.gerald.taylor
Posted Wednesday, October 03, 2012 12:20 PM
Right there with Babe
Group: General Forum Members
Last Login: Yesterday @ 7:49 AM
Points: 739,
Visits: 783
I still think you have data that isn't a date. Can you take the SQL out of your dataset and manually run it in SMSS? What does that data look like in that field?
Rob
Post #1367941
deepeshdhake
deepeshdhake
Posted Wednesday, October 03, 2012 2:55 PM
SSC Rookie
Group: General Forum Members
Last Login: Wednesday, April 10, 2013 4:08 PM
Points: 32,
Visits: 134
Hello Rob,
Can u also tell how to covert if the data type is varchar.
Thanks in advance.
Post #1368045
robert.gerald.taylor
robert.gerald.taylor
Posted Thursday, October 04, 2012 5:34 AM
Right there with Babe
Group: General Forum Members
Last Login: Yesterday @ 7:49 AM
Points: 739,
Visits: 783
In SSRS you would use the CDate() function to change from varchar() to datetime; but the issue is that you have non-date values (Amber) mixed into that column. Check your source data, see what that shows.
HTH,
Rob
Post #1368317
« Prev Topic
|
Next Topic »
11 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.