<?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>Question Re: date / time field conversion in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaa-p/12437249#M4657337</link>
    <description>&lt;P&gt;When you convert a number to text, ToText will automatically format the number to include commas as thousands separators - so it doesn't necessarily look like you think it does.  You can put your current {@Pick Start} on the report temporarily to see what I mean.  I would add a format string to your ToText so that the formula looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TOTEXT ({GPKNA.PKNSPS}, 0, "")&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If that doesn't solve the issue, let me know as I may have a few other ideas.&lt;/P&gt;&lt;P&gt;-Dell&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jul 2021 22:32:27 GMT</pubDate>
    <dc:creator>DellSC</dc:creator>
    <dc:date>2021-07-28T22:32:27Z</dc:date>
    <item>
      <title>date / time field conversion</title>
      <link>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaq-p/12437248</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;
  &lt;P&gt;In our database, we have a start and end field (datetime) which both fields are formatted as 20210708095000 which equates to YYYYMMDDHHMMSS. I want to separately extract a date and time for each using a formula.&lt;/P&gt;
  &lt;P&gt;To extract date I use:&lt;/P&gt;
  &lt;P&gt; If {GPKNA.PKNSPS} &amp;lt; 19590101 then Date (1959, 01, 01) else &lt;/P&gt;
  &lt;P&gt;Date ( Val (ToText ({GPKNA.PKNSPS}, 0 , "") [1 to 4]), &lt;/P&gt;
  &lt;P&gt; Val (ToText ({GPKNA.PKNSPS}, 0 , "") [5 to 6]), &lt;/P&gt;
  &lt;P&gt; Val (ToText ({GPKNA.PKNSPS}, 0 , "") [7 to 8]) ) &lt;/P&gt;
  &lt;P&gt;To extract time, I create the below for both start and end:&lt;/P&gt;
  &lt;P&gt;I create a formula '@Pick Start' and convert start field to text = TOTEXT ({GPKNA.PKNSPS})&lt;/P&gt;
  &lt;P&gt;then use:&lt;/P&gt;
  &lt;P&gt;stringvar x :=totext({@Pick Start},"000000"); &lt;/P&gt;
  &lt;P&gt;time(val(left(x,2)),val(mid(x,3,2)),val(right(x,2)))&lt;/P&gt;
  &lt;P&gt;This works in Crystal no issues&lt;/P&gt;
  &lt;P&gt;&lt;IMG alt="" /&gt;&lt;/P&gt;
  &lt;P&gt;However we use an automated bit of third party software to refresh this each evening and export the dataset into Excel but it wont allow for exporting to to getting the following error:&lt;/P&gt;
  &lt;P&gt;&lt;IMG alt="" /&gt;"Specified cast is not valid.Couldn't store &amp;lt;30/12/1899 00:06:18&amp;gt; in @Pick Start Column. Expeted type is TimeSpan"&lt;IMG alt="" style="font-size: 15px; color: inherit;" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG alt="" /&gt;I think I may have approached the time formulas incorrectly on the time fields, is anyone able to advise a different approach?&lt;/P&gt;
  &lt;P&gt;Have a great day!&lt;/P&gt;
  &lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 09:25:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaq-p/12437248</guid>
      <dc:creator>andy-jay51</dc:creator>
      <dc:date>2021-07-28T09:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: date / time field conversion</title>
      <link>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaa-p/12437249#M4657337</link>
      <description>&lt;P&gt;When you convert a number to text, ToText will automatically format the number to include commas as thousands separators - so it doesn't necessarily look like you think it does.  You can put your current {@Pick Start} on the report temporarily to see what I mean.  I would add a format string to your ToText so that the formula looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TOTEXT ({GPKNA.PKNSPS}, 0, "")&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If that doesn't solve the issue, let me know as I may have a few other ideas.&lt;/P&gt;&lt;P&gt;-Dell&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 22:32:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaa-p/12437249#M4657337</guid>
      <dc:creator>DellSC</dc:creator>
      <dc:date>2021-07-28T22:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: date / time field conversion</title>
      <link>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaa-p/12437250#M4657338</link>
      <description>&lt;P&gt;Good morning Dell,&lt;/P&gt;&lt;P&gt;Thank you for the idea.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" /&gt;&lt;/P&gt;&lt;P&gt;Above are the results I get using my existing set up as explained in my formula. I get date, start and end. Date I don't have any issues with and you can see the formulas do work and I can export manually no issues. Its when the third party software refreshes the report remotely and exports to its final destination that it is failing and giving me the error below &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;IMG alt="" /&gt;"Specified cast is not valid.Couldn't store &amp;lt;30/12/1899 00:06:18&amp;gt; in @Pick Start Column. Expeted type is TimeSpan"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;To get the time in the current format I have it in, I have created layered formulas:&lt;/P&gt;&lt;P&gt;Picking Start Time Code = TOTEXT ({GPKNA.PKNSPS}, 0, "")&lt;/P&gt;&lt;P&gt;Picking Start Code 2 = TONUMBER (Right ({@Picking Start Time Code}, 6))&lt;/P&gt;&lt;P&gt;Pick Start = stringvar x :=totext({@Picking Start Code 2},"000000"); time(val(left(x,2)),val(mid(x,3,2)),val(right(x,2)))&lt;/P&gt;&lt;P&gt;And that is how my time field is populated?&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 10:32:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaa-p/12437250#M4657338</guid>
      <dc:creator>andy-jay51</dc:creator>
      <dc:date>2021-07-29T10:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: date / time field conversion</title>
      <link>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaa-p/12437251#M4657339</link>
      <description>&lt;P&gt;Are you using this in the Select Expert?  Or just putting the data on the report?&lt;/P&gt;&lt;P&gt;-Dell&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 13:17:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaa-p/12437251#M4657339</guid>
      <dc:creator>DellSC</dc:creator>
      <dc:date>2021-07-29T13:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: date / time field conversion</title>
      <link>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaa-p/12437252#M4657340</link>
      <description>&lt;P&gt;It can cause an error if the default date format on the other PC is not the same as your default.&lt;/P&gt;&lt;P&gt;Or if you used a Custom date file option or if the default is set to System.&lt;/P&gt;&lt;P&gt;Likely cause is differences in default date settings....&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 13:45:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-time-field-conversion/qaa-p/12437252#M4657340</guid>
      <dc:creator>former_member11696</dc:creator>
      <dc:date>2021-07-29T13:45:02Z</dc:date>
    </item>
  </channel>
</rss>

