<?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 replacing a sql function in a load script to convert date in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539062#M201445</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a sql function that converts a datetime field to provide me MM-DD, the function is below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE FUNCTION func_convert_date( @in_date DATETIME )&lt;/P&gt;&lt;P&gt;RETURNS NVARCHAR(255)&lt;/P&gt;&lt;P&gt;AS&lt;/P&gt;&lt;P&gt;BEGIN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DECLARE @str_date nvarchar(255);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @str_date = ( SELECT RIGHT('0' + CONVERT(VARCHAR(2), DATEPART(MONTH, @in_date)), 2) + '-' + RIGHT('0' + CONVERT(VARCHAR(2), DATEPART(DAY, @in_date)), 2) );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RETURN @str_date;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im trying to apply this to a load script, or find an alternative method to convert a datetime into MM-DD. Is there a way to do this in the load script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Oct 2013 21:18:43 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-10-28T21:18:43Z</dc:date>
    <item>
      <title>replacing a sql function in a load script to convert date</title>
      <link>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539062#M201445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a sql function that converts a datetime field to provide me MM-DD, the function is below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE FUNCTION func_convert_date( @in_date DATETIME )&lt;/P&gt;&lt;P&gt;RETURNS NVARCHAR(255)&lt;/P&gt;&lt;P&gt;AS&lt;/P&gt;&lt;P&gt;BEGIN&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DECLARE @str_date nvarchar(255);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @str_date = ( SELECT RIGHT('0' + CONVERT(VARCHAR(2), DATEPART(MONTH, @in_date)), 2) + '-' + RIGHT('0' + CONVERT(VARCHAR(2), DATEPART(DAY, @in_date)), 2) );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RETURN @str_date;&lt;/P&gt;&lt;P&gt;END;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im trying to apply this to a load script, or find an alternative method to convert a datetime into MM-DD. Is there a way to do this in the load script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 21:18:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539062#M201445</guid>
      <dc:creator />
      <dc:date>2013-10-28T21:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a sql function in a load script to convert date</title>
      <link>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539063#M201446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;the equivalent in QlikView script would be something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date(Date#(DateField, ' Put here the original format of the date field eg. YYYYMMDD, DD/MM/YYYY '), ' Put here the desired format, in this case MM-DD ')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so the code would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Field1,&lt;/P&gt;&lt;P&gt;Field2,&lt;/P&gt;&lt;P&gt;Date(Date#(DateField, 'YYYYMMDD'), 'MM-DD') as DateName;&lt;/P&gt;&lt;P&gt;SQL Select *&lt;/P&gt;&lt;P&gt;FROM Table;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 22:19:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539063#M201446</guid>
      <dc:creator>jaimeaguilar</dc:creator>
      <dc:date>2013-10-28T22:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a sql function in a load script to convert date</title>
      <link>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539064#M201447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try like thi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;*,&lt;/P&gt;&lt;P&gt;Date(Date#(DateDimensionName, 'DateFormat'), 'MM-DD') as Date;&lt;/P&gt;&lt;P&gt;SQL Select *&lt;/P&gt;&lt;P&gt;FROM Table;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replace &lt;STRONG&gt;DateDimensionName &lt;/STRONG&gt;with your date field, and DateFormat with the format specifiers of your datefield (MM/DD/YYYY etc).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jagan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2013 02:21:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539064#M201447</guid>
      <dc:creator>jagan</dc:creator>
      <dc:date>2013-10-29T02:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a sql function in a load script to convert date</title>
      <link>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539065#M201448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys! this 'almost' works.. The reload of the script runs, I see the field but I get an empty list box. All the other fields from the table appear, so Im sure theres just one small thing Im missing in this function. My load statement is below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;*,&lt;/P&gt;&lt;P&gt;Date(Date#(BIRTHDATE, 'YYYY-MM-DD'), 'MM-DD') as Birthday;&lt;/P&gt;&lt;P&gt;SQL Select *&lt;/P&gt;&lt;P&gt;FROM&amp;nbsp; TABLE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The BIRTHDATE field is DATETIME format, would that make a difference?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Grant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2013 10:13:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539065#M201448</guid>
      <dc:creator />
      <dc:date>2013-10-29T10:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: replacing a sql function in a load script to convert date</title>
      <link>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539066#M201449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got it guys! Floor worked like a charm&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;*,&lt;/P&gt;&lt;P&gt;Date( Floor( BIRTHDATE ), 'MM-DD') as Birthday;&lt;/P&gt;&lt;P&gt;SQL Select *&lt;/P&gt;&lt;P&gt;FROM&amp;nbsp; TABLE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help, shot me in the right direction&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Grant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2013 10:37:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/replacing-a-sql-function-in-a-load-script-to-convert-date/m-p/539066#M201449</guid>
      <dc:creator />
      <dc:date>2013-10-29T10:37:17Z</dc:date>
    </item>
  </channel>
</rss>

