<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to convert a text to dateTime</title><link>https://community.appian.com/discussions/f/rules/34549/how-to-convert-a-text-to-datetime</link><description>Hi All, 
 My requirement is to read the excel sheet data and to write it into Database table from Appian. 
 The excel sheet contains some dateTime columns. But when we read the excel sheet in Appian, it considers all the columns as text, so I am getting</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132515?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 17:00:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:42704970-26f1-4931-ba80-d1447edd7607</guid><dc:creator>Jansi J</dc:creator><description>&lt;p&gt;Thanks for the clarification Mike.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132497?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 13:16:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ffef2237-416d-4746-9940-5e8d09a5263e</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="55817" url="~/discussions/f/rules/34549/how-to-convert-a-text-to-datetime/132439"]is it is possible to save/fetch the date and time without time zone?[/quote]
&lt;p&gt;remember that Appian datestamps are inherently stored in GMT, regardless of what you do, the only difference is what you see displayed.&amp;nbsp; My rule above has 2 different styles of output (depending on the GMT parameter) which was intended to accept stamps that need to be converted from GMT prior to output (since sometimes the text values we get are really a local timestamp and Appian will interpret them as a literal GMT value then convert too far).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132492?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 11:38:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:7bbf5638-3f24-40b7-b9de-9a55d2cbe296</guid><dc:creator>Vishal Agarwal</dc:creator><description>&lt;p&gt;Try this-&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;input -&amp;nbsp;&amp;quot;03-04-2022 09:14:36&amp;quot; - Text&lt;/p&gt;
&lt;p&gt;output -&amp;nbsp;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;4/3/2022 9:14 AM - DateTime&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;a!localVariables(&lt;br /&gt;local!date: split(ri!date,&amp;quot; &amp;quot;),&lt;br /&gt;local!time: split(ri!date,&amp;quot; &amp;quot;),&lt;br /&gt;local!concat: concat(todate(local!date[1]),&amp;quot; &amp;quot;,totime(local!time[2])),&lt;br /&gt;split(todatetime(local!concat),&amp;quot; G&amp;quot;)[1]&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132439?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 21:21:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2e2d2114-aa54-4b6e-abe2-bc716f7d3413</guid><dc:creator>Jansi J</dc:creator><description>&lt;p&gt;Hi Mike, Thanks for your response.&lt;/p&gt;
&lt;p&gt;It gives the expected output, but is it is possible to save/fetch the date and time without time zone?&lt;/p&gt;
&lt;p&gt;Input String :&amp;nbsp;&amp;quot;2024-01-31 09:14:36&amp;quot;&lt;/p&gt;
&lt;p&gt;Current output from your code :&amp;nbsp;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;1/31/2024 9:14 AM GMT-05:00&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Expected output :&amp;nbsp;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;1/31/2024 9:14 AM&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132438?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 19:23:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b6cf30ed-a34b-4e38-92a8-35ccd261cab8</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="244047" url="~/discussions/f/rules/34549/how-to-convert-a-text-to-datetime/132431"]docs.appian.com/.../fnc_conversion_todatetime.html[/quote]
&lt;p&gt;this isn&amp;#39;t &amp;quot;parseDateTime()&amp;quot; which you quoted above - the function &amp;quot;todatetime()&amp;quot; (referenced in your link here) does not convert ISO-8601 date/time strings (i.e. &amp;quot;yyyy-mm-dd&amp;quot; etc), only &amp;quot;mm/dd/yy&amp;quot; style strings.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132437?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 19:22:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4e032b67-b902-4e50-a767-b439ffe75dc7</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I&amp;#39;ve written it from scratch in the past, if you want (note it requires Regex Functions plug-in)&lt;/p&gt;
&lt;p&gt;Parsing ISO-8601 date/time&lt;/p&gt;
&lt;p&gt;&lt;em&gt;RULE_Utility_parseIsoDateTime()&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;if(
  or(
    isnull(ri!dateTimeString),
    not(regexmatch(
      pattern: &amp;quot;[12]\d\d\d-[01]{0,1}\d-[0123]{0,1}\d [012]\d:[012345]\d:[012345]\d&amp;quot;,
      searchString: ri!dateTimeString,
      regexFlags: &amp;quot;s&amp;quot;
    )) 
  ),
  null(),
  
  a!localVariables(
    local!parts: split(ri!dateTimeString, &amp;quot; &amp;quot;),
    local!dateParts: split(local!parts[1], &amp;quot;-&amp;quot;),
    local!timeParts: split(local!parts[2], &amp;quot;:&amp;quot;),
    local!gmtTime: datetime(
      local!dateParts[1],
      local!dateParts[2],
      local!dateParts[3],
      local!timeParts[1],
      local!timeParts[2],
      local!timeParts[3]
    ),
    
    if(
      ri!fromGmt,
      local!gmtTime,
      gmt(local!gmtTime)
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132431?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 18:12:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cfaa6b3a-f755-46c9-b094-fd8435b39195</guid><dc:creator>SRINIVAS M</dc:creator><description>&lt;p&gt;&lt;a href="https://docs.appian.com/suite/help/24.1/fnc_conversion_todatetime.html#:~:text=Using%20todatetime()%20with%20arrays&amp;amp;text=When%20operating%20on%20arrays%2C%20it,will%20return%20a%20Datetime%20Array."&gt;docs.appian.com/.../fnc_conversion_todatetime.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132430?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 18:09:33 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1dd1e9be-00f7-4234-acc8-e816d396e16a</guid><dc:creator>Jansi J</dc:creator><description>&lt;p&gt;I tried this -&amp;nbsp;&lt;span&gt;value(local!convertedDateTime, &amp;quot;MM/dd/yyyy hh:mm a&amp;quot;) but&amp;nbsp;&lt;/span&gt;It gives me the output as&amp;nbsp;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;1/30/2024 11:14 PM GMT-05:00 for this input &amp;quot;2024-01-31 09:14:36&amp;quot;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;Code:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;a!localVariables(&lt;br /&gt; local!dateAndTime: split(&amp;quot;2024-01-31 09:14:36&amp;quot;, &amp;quot; &amp;quot;),&lt;br /&gt; local!date: split(local!dateAndTime[1], &amp;quot;-&amp;quot;),&lt;br /&gt; local!time: split(local!dateAndTime[2], &amp;quot;:&amp;quot;),&lt;br /&gt; local!convertedDateTime:datetime(&lt;br /&gt; local!date[1],&lt;br /&gt; local!date[2],&lt;br /&gt; local!date[3],&lt;br /&gt; tointeger(local!time[1]),&lt;br /&gt; tointeger(local!time[2]),&lt;br /&gt; tointeger(local!time[3]),&lt;br /&gt; ),&lt;br /&gt; value(local!convertedDateTime, &amp;quot;MM/dd/yyyy hh:mm a&amp;quot;)&lt;br /&gt; )&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;But my expected output is 1/31/2024 09:14 AM.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132429?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 18:06:42 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c97e86c2-d6e9-438c-9006-ed4d6a4e89de</guid><dc:creator>Jansi J</dc:creator><description>&lt;p&gt;Sorry,we dont have parseDateTime function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132425?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 17:48:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b1d9840d-0750-4f2c-bd0d-ae888ee989d7</guid><dc:creator>SRINIVAS M</dc:creator><description>&lt;p&gt;/* Example conversion assuming &amp;#39;excelDateTimeText&amp;#39; is the Text variable with your date-time string */&lt;/p&gt;
&lt;p&gt;/* First, replace the &amp;#39;-&amp;#39; with &amp;#39;/&amp;#39; to match Appian&amp;#39;s date format */&lt;br /&gt;!dateString = replace(excelDateTimeText, &amp;quot;-&amp;quot;, &amp;quot;/&amp;quot;);&lt;/p&gt;
&lt;p&gt;/* Then, use the toDatetime() function to convert the string to DateTime data type */&lt;br /&gt;!dateTime = toDatetime(!dateString, &amp;quot;MM/dd/yyyy HH:mm:ss&amp;quot;);&lt;/p&gt;
&lt;p&gt;/* Now, &amp;#39;!dateTime&amp;#39; is an Appian DateTime data type */&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132424?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 17:47:49 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6f3320c6-fbe1-4c60-ab8b-541c45ddbeae</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;Instead of format, use value with a format string:&lt;br /&gt;value(local!convertedDateTime, &amp;quot;MM/dd/yyyy hh:mm a&amp;quot;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132423?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 17:44:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:51a8be0f-43b6-4624-8b01-119b4a3e71fd</guid><dc:creator>Jansi J</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi, thanks for your response. I want the output in Date time format, not&amp;nbsp;as a text.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132422?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 17:42:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1f24c353-c8ba-4a23-bff0-cc58062eb82b</guid><dc:creator>Jansi J</dc:creator><description>&lt;p&gt;Hi, thanks for your response. It shows me like format function is not available.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132420?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 17:36:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:11eb7b59-a1b9-48e5-8d91-dad13365b999</guid><dc:creator>SRINIVAS M</dc:creator><description>&lt;p&gt;Example for converting &amp;quot;2024-01-31 09:14:36&amp;quot; to &amp;quot;1/31/2024 9:14 AM&amp;quot; *&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Step 1: Parse the DateTime text&amp;nbsp;&lt;br /&gt;!dateTime = parseDateTime(&amp;quot;2024-01-31 09:14:36&amp;quot;, &amp;quot;yyyy-MM-dd HH:mm:ss&amp;quot;);&lt;/p&gt;
&lt;p&gt;Step 2: Format the DateTime to desired format&amp;nbsp;&lt;br /&gt;!formattedDateTime = toFormattedString(!dateTime, &amp;quot;M/d/yyyy h:mm a&amp;quot;);&lt;/p&gt;
&lt;p&gt;Output the formatted DateTime&amp;nbsp;&lt;br /&gt;!formattedDateTime&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Note:&lt;span&gt;Apply this logic for each dateTime string you extract from your Excel sheet. Remember, before writing to the database, ensure that your CDT/columns designed to hold DateTime values are indeed set to accept DateTime data types.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to convert a text to dateTime</title><link>https://community.appian.com/thread/132419?ContentTypeID=1</link><pubDate>Tue, 02 Apr 2024 17:33:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f9642f58-3502-4c2a-a0e8-1ed5c6271a2f</guid><dc:creator>Shubham Aware</dc:creator><description>&lt;p&gt;Create a&amp;nbsp;dateTime&amp;nbsp;local variable.&lt;br /&gt;Use&amp;nbsp;todatetime(text!excelDateTimeColumn)&amp;nbsp;to convert text to&amp;nbsp;dateTime.&lt;br /&gt;Use&amp;nbsp;format(local!convertedDateTime, &amp;quot;MM/dd/yyyy hh:mm a&amp;quot;)&amp;nbsp;to format the date.&lt;br /&gt;Write the&amp;nbsp;text!desiredOutput&amp;nbsp;variable to the database (formatted date).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>