<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Convert Date to String in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Convert-Date-to-String/m-p/411633#M66117</link>
    <description>&lt;P&gt;If you want to convert it into a string with padding for zeros this should work in all cases:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Char(Year(Today())) || "-" || Substr("00", 1,  2 - Length(Char(Month(Today())))) || Char(Month(Today())) || "-" || Substr("00", 1 , 2 - Length(Char(Day(Today())))) || Char(Day(Today()));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or then you can use something like this which should also work in most of the cases (not sure if JMP will have issue with this specific format on some regional settings):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Format(Today(), "yyyy-mm-dd");&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled 3",
	Add Rows(0),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);

dt &amp;lt;&amp;lt; Set Table Variable("LastRunDate", Format(Today(), "yyyy-mm-dd"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Aug 2021 18:07:02 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2021-08-20T18:07:02Z</dc:date>
    <item>
      <title>Convert Date to String</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-Date-to-String/m-p/411626#M66116</link>
      <description>&lt;P&gt;I'm trying to create a data table variable that is a string representation of date in the format yyyy-mm-dd.&amp;nbsp; I can define a variable in the proper format and set it as a data table variable as shown here.&lt;/P&gt;&lt;P&gt;datetime = "2021-08-01";&lt;BR /&gt;dt = Current Data Table();&lt;BR /&gt;dt &amp;lt;&amp;lt; Set Table Variable( "LastRunDate", datetime );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I want to obtain the current datetime and convert it to a string in the format yyyy-mm-dd so that I can save it as a data table variable.&amp;nbsp; What is the best/easiest way to accomplish this?&amp;nbsp; I&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:55:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-Date-to-String/m-p/411626#M66116</guid>
      <dc:creator>terapin</dc:creator>
      <dc:date>2023-06-09T19:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date to String</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-Date-to-String/m-p/411633#M66117</link>
      <description>&lt;P&gt;If you want to convert it into a string with padding for zeros this should work in all cases:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Char(Year(Today())) || "-" || Substr("00", 1,  2 - Length(Char(Month(Today())))) || Char(Month(Today())) || "-" || Substr("00", 1 , 2 - Length(Char(Day(Today())))) || Char(Day(Today()));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or then you can use something like this which should also work in most of the cases (not sure if JMP will have issue with this specific format on some regional settings):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Format(Today(), "yyyy-mm-dd");&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled 3",
	Add Rows(0),
	Compress File When Saved(1),
	New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([]))
);

dt &amp;lt;&amp;lt; Set Table Variable("LastRunDate", Format(Today(), "yyyy-mm-dd"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Aug 2021 18:07:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-Date-to-String/m-p/411633#M66117</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-08-20T18:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date to String</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-Date-to-String/m-p/411681#M66119</link>
      <description>&lt;P&gt;Both solutions worked.&amp;nbsp; Thanks for the quick suggestion.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 21:22:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-Date-to-String/m-p/411681#M66119</guid>
      <dc:creator>terapin</dc:creator>
      <dc:date>2021-08-20T21:22:52Z</dc:date>
    </item>
  </channel>
</rss>

