{"id":122,"date":"2009-04-15T07:54:52","date_gmt":"2009-04-15T13:54:52","guid":{"rendered":"https:\/\/jackdonnell.com\/?p=122"},"modified":"2016-01-20T16:40:26","modified_gmt":"2016-01-20T22:40:26","slug":"ssrs-format-and-formatedatetime","status":"publish","type":"post","link":"https:\/\/jackdonnell.com\/?p=122","title":{"rendered":"SSRS &#8211; Format() and FormateDateTime()"},"content":{"rendered":"<p>Found this reference &#8230; JUST IN TIME!<\/p>\n<p><b>Thanks Thavash <\/b>This is by far my most visited page.<\/p>\n<p><a href=\"http:\/\/thavash.spaces.live.com\/blog\/cns!CF6232111374DFD2!155.entry\">http:\/\/thavash.spaces.live.com\/blog\/cns!CF6232111374DFD2!155.entry<\/a><\/p>\n<div id=\"LastMDatecns!CF6232111374DFD2!155\">April 10<\/div>\n<h4 id=\"subjcns!CF6232111374DFD2!155\" class=\"beTitle\">Working with Dates in Reporting Services<\/h4>\n<div id=\"msgcns!CF6232111374DFD2!155\" class=\"bvMsg\">\n<div>As with any other technology ( eg. SQL , C# ), you always find people running into problems with processing of dates. I was asked today\u00a0, &#8220;How to I format dates when using the Date Picker and sending it through to a stored procedure&#8221; ? Let&#8217;s have a look &#8230;.<\/div>\n<div><\/div>\n<div>1) The <strong>FormatDateTime <\/strong>command<\/div>\n<div><\/div>\n<div>This is pretty easy to use, but maybe a bit limiting. You can specify 1 of 4 formats using the command arguments. Let&#8217;s say we have selected a date such as 10th April 2007 , our results will be as follows :<\/div>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td bgcolor=\"#eee8aa\" width=\"350\"><strong>Command<\/strong><\/td>\n<td bgcolor=\"#eee8aa\" width=\"350\"><strong>Result<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"350\">FormatDateTime(Parameters!Date.Value,1)<\/td>\n<td width=\"350\">Tuesday, April 10, 2007<\/td>\n<\/tr>\n<tr>\n<td width=\"350\">FormatDateTime(Parameters!Date.Value,2)<\/td>\n<td width=\"350\">4\/10\/2007<\/td>\n<\/tr>\n<tr>\n<td width=\"350\">FormatDateTime(Parameters!Date.Value,3)<\/td>\n<td width=\"350\">12:00:00 AM<\/td>\n<\/tr>\n<tr>\n<td width=\"350\">FormatDateTime(Parameters!Date.Value,4)<\/td>\n<td width=\"350\">00:00<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#8230;but the better way to do it would be to use &#8230;<\/p>\n<p>2) The <strong>Format<\/strong> command and specify the exact format you require. For example&#8230;<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td bgcolor=\"#eee8aa\" width=\"350\"><strong>Command<\/strong><\/td>\n<td bgcolor=\"#eee8aa\" width=\"350\"><strong>Result<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"350\">Format(Parameters!Date.Value,&#8221;dd-MM-yyyy&#8221;)<\/td>\n<td width=\"350\">10-04-2007<\/td>\n<\/tr>\n<tr>\n<td width=\"350\">Format(Parameters!Date.Value,&#8221;dd\/MM\/yyyy&#8221;)<\/td>\n<td width=\"350\">10\/04\/2007<\/td>\n<\/tr>\n<tr>\n<td width=\"350\">Format(Parameters!Date.Value,&#8221;MMM-dd-yyyy&#8221;)<\/td>\n<td width=\"350\">Apr-10-2007<\/td>\n<\/tr>\n<tr>\n<td width=\"350\">Format(Parameters!Date.Value,&#8221;MMM-dd-yy&#8221;)<\/td>\n<td width=\"350\">Apr-10-07<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>So 3 M&#8217;s give you &#8220;Apr&#8221; &#8230;.anyway this is quite useful if you&#8217;re looking for Day\/Month\/Year , since the system will default to MM\/DD\/YYYY.<\/p>\n<p>Using this you should be able to display the date format you want , or send through a particular format to a Stored Proc.<\/p>\n<p><strong>EDITED 22\/08\/2007<\/strong> : If the Format Command doesn&#8217;t work , try converting the value to a date , eg.<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td align=\"middle\" bgcolor=\"#dcdcdc\" width=\"700\"><strong><span style=\"font-size: xx-small;\">Format(Cdate(Parameters!Date.Value),&#8221;dd-MM-yyyy&#8221;)<\/span> <\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>SSRS Date Formating reference.. Thanks Thavash!!! You are a Rock Star!<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/jackdonnell.com\/?p=122\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[60,58,138,113,22,51,5],"tags":[280,303,260,339,338,67,265,315,249,35,36,295,52,298,291],"class_list":["post-122","post","type-post","status-publish","format-standard","hentry","category-dotnetnuke","category-os","category-programming","category-reportingbi","category-sql-server","category-ssrs","category-t-sql","tag-date-format","tag-dba","tag-developer","tag-format","tag-formatdatetime","tag-how-to","tag-learning","tag-query","tag-script","tag-select","tag-sql","tag-sql-server","tag-ssms","tag-ssrs","tag-t-sql"],"_links":{"self":[{"href":"https:\/\/jackdonnell.com\/index.php?rest_route=\/wp\/v2\/posts\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jackdonnell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jackdonnell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jackdonnell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jackdonnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=122"}],"version-history":[{"count":7,"href":"https:\/\/jackdonnell.com\/index.php?rest_route=\/wp\/v2\/posts\/122\/revisions"}],"predecessor-version":[{"id":634,"href":"https:\/\/jackdonnell.com\/index.php?rest_route=\/wp\/v2\/posts\/122\/revisions\/634"}],"wp:attachment":[{"href":"https:\/\/jackdonnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jackdonnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jackdonnell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}