{"id":43,"date":"2008-04-18T14:28:22","date_gmt":"2008-04-18T19:28:22","guid":{"rendered":"http:\/\/www.cfchimp.com\/wordpress\/?p=43"},"modified":"2024-12-05T20:04:02","modified_gmt":"2024-12-06T01:04:02","slug":"cfgrid-dateformat","status":"publish","type":"post","link":"https:\/\/csimmons.dev\/blog\/2008\/04\/cfgrid-dateformat\/","title":{"rendered":"CFGRID DateFormat"},"content":{"rendered":"<p>For some reason when you have a datetime field in a  cfgrid column it displays in a long format like this: Nov 17 2006 01:00:00<\/p>\n<h6><strong> Fig 1 (Below) A date displayed in cfgrid<\/strong><\/h6>\n<p><img decoding=\"async\" src=\"https:\/\/csimmons.dev\/blog\/wp-content\/uploads\/2008\/04\/cfgrid_before.jpg\" alt=\"CFGRID DateFormat Before\" \/><\/p>\n<p>If we work a little SQL magic (using &#8220;CONVERT&#8221;) in the cfquery though we can do the formatting we want, which is: 11\/17\/2006.  Refer to the &#8220;styles&#8221; listed in Figure 3 to see what formatting is available.<\/p>\n<p><strong>Coldfusion Query:<\/strong><br \/>\n<code><cfquery name=\"q_record_note\"><br \/>\nSELECT note_id,note_text,<br \/>\nCONVERT(varchar,note_date,101) as note_date<br \/>\nFROM tbl_notes<br \/>\nORDER BY note_date<br \/>\n<\/cfquery><\/code><\/p>\n<h6><strong><strong>Fig 2 (Below) A date displayed in cfgrid after using CONVERT in cfquery<\/strong><\/strong><\/h6>\n<p><img decoding=\"async\" src=\"https:\/\/csimmons.dev\/blog\/wp-content\/uploads\/2008\/04\/cfgrid_after.jpg\" alt=\"CFGRID DateFormat After\" \/><\/p>\n<h6><strong><strong>Fig 3 (Below) A <\/strong><\/strong>helpful list of &#8220;styles&#8221; to use with the SQL CONVERT function<\/h6>\n<table height=\"380\" width=\"450\">\n<tr>\n<td width=\"25%\"><strong><font color=\"#003366\">Style ID<\/font><\/strong><\/td>\n<td width=\"75%\"><strong><font color=\"#003366\">Style Type<\/font><\/strong><\/td>\n<\/tr>\n<tr>\n<td>0 or 100<\/td>\n<td>mon dd yyyy hh:miAM (or PM)<\/td>\n<\/tr>\n<tr>\n<td>101<\/td>\n<td>mm\/dd\/yy<\/td>\n<\/tr>\n<tr>\n<td>102<\/td>\n<td>yy.mm.dd<\/td>\n<\/tr>\n<tr>\n<td>103<\/td>\n<td>dd\/mm\/yy<\/td>\n<\/tr>\n<tr>\n<td>104<\/td>\n<td>dd.mm.yy<\/td>\n<\/tr>\n<tr>\n<td>105<\/td>\n<td>dd-mm-yy<\/td>\n<\/tr>\n<tr>\n<td>106<\/td>\n<td>dd mon yy<\/td>\n<\/tr>\n<tr>\n<td>107<\/td>\n<td>Mon dd, yy<\/td>\n<\/tr>\n<tr>\n<td>108<\/td>\n<td>hh:mm:ss<\/td>\n<\/tr>\n<tr>\n<td>9 or 109<\/td>\n<td>mon dd yyyy hh:mi:ss:mmmAM (or PM)<\/td>\n<\/tr>\n<tr>\n<td>110<\/td>\n<td>mm-dd-yy<\/td>\n<\/tr>\n<tr>\n<td>111<\/td>\n<td>yy\/mm\/dd<\/td>\n<\/tr>\n<tr>\n<td>112<\/td>\n<td>yymmdd<\/td>\n<\/tr>\n<tr>\n<td>13 or 113<\/td>\n<td>dd mon yyyy hh:mm:ss:mmm(24h)<\/td>\n<\/tr>\n<tr>\n<td>114<\/td>\n<td>hh:mi:ss:mmm(24h)<\/td>\n<\/tr>\n<tr>\n<td>20 or 120<\/td>\n<td>yyyy-mm-dd hh:mi:ss(24h)<\/td>\n<\/tr>\n<tr>\n<td>21 or 121<\/td>\n<td>yyyy-mm-dd hh:mi:ss.mmm(24h)<\/td>\n<\/tr>\n<tr>\n<td>126<\/td>\n<td>yyyy-mm-dd Thh:mm:ss.mmm(no spaces)<\/td>\n<\/tr>\n<tr>\n<td>130<\/td>\n<td>dd mon yyyy hh:mi:ss:mmmAM<\/td>\n<\/tr>\n<tr>\n<td>131<\/td>\n<td>dd\/mm\/yy hh:mi:ss:mmmAM<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>For some reason when you have a datetime field in a cfgrid column it displays in a long format like this: Nov 17 2006 01:00:00 Fig 1 (Below) A date displayed in cfgrid If we work a little SQL magic (using &#8220;CONVERT&#8221;) in the cfquery though we can do the formatting we want, which is: &#8230; <a title=\"CFGRID DateFormat\" class=\"read-more\" href=\"https:\/\/csimmons.dev\/blog\/2008\/04\/cfgrid-dateformat\/\" aria-label=\"Read more about CFGRID DateFormat\">Read more<\/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,"_cloudinary_featured_overwrite":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[68],"tags":[48,16],"class_list":["post-43","post","type-post","status-publish","format-standard","hentry","category-developer","tag-coldfusion","tag-sql"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pbVg43-H","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/43","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":0,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/43\/revisions"}],"wp:attachment":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/media?parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/categories?post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/tags?post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}