{"id":274,"date":"2011-07-19T15:55:58","date_gmt":"2011-07-19T20:55:58","guid":{"rendered":"http:\/\/peshvar.com\/myblog\/?p=274"},"modified":"2015-01-31T14:40:43","modified_gmt":"2015-01-31T19:40:43","slug":"sql-2005-mm-ddd-yy-fortmat","status":"publish","type":"post","link":"https:\/\/peshvar.com\/myblog\/2011\/07\/19\/sql-2005-mm-ddd-yy-fortmat\/","title":{"rendered":"SQL 2005 MM-DDD-YY format"},"content":{"rendered":"<p>To format a date as MM-DDD-YY<\/p>\n<p>Today:<br \/>\nREPLACE(right(UPPER(convert(varchar(20),getdate() ,06)), len(convert(varchar(20),getdate(),06))), &#8216; &#8216;, &#8216;-&#8216;)<\/p>\n<p>to get Yesterday&#8217;s date:<\/p>\n<p>PRINT REPLACE(right(UPPER(convert(varchar(20),getdate()-1 ,06)), len(convert(varchar(20),getdate()-1,06))), &#8216; &#8216;, &#8216;-&#8216;)<\/p>\n<p>Extra date format for Microsoft SQL:<br \/>\n<!--more--><\/p>\n<p>\u2013 Microsoft SQL Server T-SQL date and datetime formats<\/p>\n<p>\u2013 Date time formats \u2013 mssql datetime<\/p>\n<p>\u2013 MSSQL getdate returns current system date and time in standard internal format<\/p>\n<p>SELECT convert(varchar, getdate(), 100) \u2013 mon dd yyyy hh:mmAM (or PM)<\/p>\n<p>\u2013 Oct 2 2008 11:01AM<\/p>\n<p>SELECT convert(varchar, getdate(), 101) \u2013 mm\/dd\/yyyy &#8211; 10\/02\/2008<\/p>\n<p>SELECT convert(varchar, getdate(), 102) \u2013 yyyy.mm.dd \u2013 2008.10.02<\/p>\n<p>SELECT convert(varchar, getdate(), 103) \u2013 dd\/mm\/yyyy<\/p>\n<p>SELECT convert(varchar, getdate(), 104) \u2013 dd.mm.yyyy<\/p>\n<p>SELECT convert(varchar, getdate(), 105) \u2013 dd-mm-yyyy<\/p>\n<p>SELECT convert(varchar, getdate(), 106) \u2013 dd mon yyyy<\/p>\n<p>SELECT convert(varchar, getdate(), 107) \u2013 mon dd, yyyy<\/p>\n<p>SELECT convert(varchar, getdate(), 108) \u2013 hh:mm:ss<\/p>\n<p>SELECT convert(varchar, getdate(), 109) \u2013 mon dd yyyy hh:mm:ss:mmmAM (or PM)<\/p>\n<p>\u2013 Oct 2 2008 11:02:44:013AM<\/p>\n<p>SELECT convert(varchar, getdate(), 110) \u2013 mm-dd-yyyy<\/p>\n<p>SELECT convert(varchar, getdate(), 111) \u2013 yyyy\/mm\/dd<\/p>\n<p>SELECT convert(varchar, getdate(), 112) \u2013 yyyymmdd<\/p>\n<p>SELECT convert(varchar, getdate(), 113) \u2013 dd mon yyyy hh:mm:ss:mmm<\/p>\n<p>\u2013 02 Oct 2008 11:02:07:577<\/p>\n<p>SELECT convert(varchar, getdate(), 114) \u2013 hh:mm:ss:mmm(24h)<\/p>\n<p>SELECT convert(varchar, getdate(), 120) \u2013 yyyy-mm-dd hh:mm:ss(24h)<\/p>\n<p>SELECT convert(varchar, getdate(), 121) \u2013 yyyy-mm-dd hh:mm:ss.mmm<\/p>\n<p>SELECT convert(varchar, getdate(), 126) \u2013 yyyy-mm-ddThh:mm:ss.mmm<\/p>\n<p>\u2013 2008-10-02T10:52:47.513<\/p>\n<p>\u2013 SQL create different date styles with t-sql string functions<\/p>\n<p>SELECT replace(convert(varchar, getdate(), 111), \u2018\/\u2019, \u2018 \u2018) \u2013 yyyy mm dd<\/p>\n<p>SELECT convert(varchar(7), getdate(), 126) \u2013 yyyy-mm<\/p>\n<p>SELECT right(convert(varchar, getdate(), 106), 8) \u2013 mon yyyy<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To format a date as MM-DDD-YY Today: REPLACE(right(UPPER(convert(varchar(20),getdate() ,06)), len(convert(varchar(20),getdate(),06))), &#8216; &#8216;, &#8216;-&#8216;) to get Yesterday&#8217;s date: PRINT REPLACE(right(UPPER(convert(varchar(20),getdate()-1 ,06)), [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[4,32],"tags":[],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-information-technology","category-all-about-sql-2000-and-2005"],"_links":{"self":[{"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/comments?post=274"}],"version-history":[{"count":6,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":317,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/posts\/274\/revisions\/317"}],"wp:attachment":[{"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/media?parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/categories?post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/tags?post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}