<?xml version="1.0" encoding="UTF-8" ?><!-- generator=Zoho Sites --><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><atom:link href="https://getaligned.zohosites.com/blogs/tag/lists/feed" rel="self" type="application/rss+xml"/><title>Aligned Solutions Consulting - Blog #lists</title><description>Aligned Solutions Consulting - Blog #lists</description><link>https://getaligned.zohosites.com/blogs/tag/lists</link><lastBuildDate>Thu, 25 Dec 2025 01:44:30 -0800</lastBuildDate><generator>http://zoho.com/sites/</generator><item><title><![CDATA[Handy SQL Statements &amp; C# Expressions]]></title><link>https://getaligned.zohosites.com/blogs/post/handy-sql-statements-expressions</link><description><![CDATA[Below is a living list of handy SQL Statements &amp; C# Expressions I have come across to make things easier.&nbsp; This is primarily a reference for ]]></description><content:encoded><![CDATA[<div class="zpcontent-container blogpost-container "><div data-element-id="elm_jmI1Mq98RSi_CmM3CvOATA" data-element-type="section" class="zpsection "><style type="text/css"></style><div class="zpcontainer-fluid zpcontainer"><div data-element-id="elm_OSiN-wcWRTCeGei-i6YiQA" data-element-type="row" class="zprow zprow-container zpalign-items- zpjustify-content- " data-equal-column=""><style type="text/css"></style><div data-element-id="elm_tPe-8r3LQVy0tjm-UeHvgA" data-element-type="column" class="zpelem-col zpcol-12 zpcol-md-12 zpcol-sm-12 zpalign-self- "><style type="text/css"></style><div data-element-id="elm_e-LMys5_Q0SAKNgXVsPDvw" data-element-type="text" class="zpelement zpelem-text "><style></style><div class="zptext zptext-align-center " data-editor="true"><div>Below is a living list of handy SQL Statements &amp; C# Expressions I have come across to make things easier.&nbsp; This is primarily a reference for myself. (Note: Copy &amp; Pasting these will most likely not work since these are segments of SQL and often times you need to replace some values with values from your environment) <h2>SQL</h2><ul><li style="list-style-type:none;"><ul><li><strong>DATE &amp; TIME</strong>(Depending on your&nbsp;environment NOW(), TODAY(), GETDATE()&nbsp;or someother date/time value maybe used) <ul><li><strong>Year To Date:</strong><ul><li>dateadd(yy, DATEDIFF(yy, 0, NOW()),0 )</li></ul></li><li><strong>Date Format CCYYMMDD:</strong><ul><li>convert(varchar, NOW(), 112)</li></ul></li><li><strong>Current Time Format HH:MM:SS for seconds from midnight:</strong><ul><li>CONVERT(varchar, DATEADD(ss, NOW(), 0), 108)</li></ul></li><li><strong>Current Time Format HHMMSS for seconds from midnight:</strong><ul><li>REPLACE(CONVERT(varchar, DATEADD(ss, NOW(), 0), 108), ':', ''</li></ul></li><li><strong>First Day of Current Year</strong><ul><li>DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0)</li></ul></li><li><strong>First Day of Last Year</strong><ul><li>DATEADD(YEAR, DATEDIFF(YEAR, 0, DATEADD(YEAR, -1, GETDATE())), 0)</li></ul></li></ul></li><li><strong>STRINGS</strong><ul><li><strong>Substring:</strong> MID() is NOT an T-SQL function, but SUBSTRING() is! <ul><li>SUBSTRING(field, start position, length)</li></ul></li></ul></li><li><strong>ROW COUNT (Windowing)</strong><ul><li>(ROW_Number()&nbsp;OVER(Partition by order by )) as </li></ul></li></ul></li></ul><b>SPLITING STRINGS ON WORDS</b><ul><li style="list-style-type:none;"><ul><li>SELECT <span style="color:rgb(0, 0, 0);">IIF(LEN(Part.Description) &lt; 30, </span><span style="color:rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:rgb(0, 0, 0);">Part.Description, </span><span style="color:rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:rgb(0, 0, 0);">LEFT(LEFT(Part.Description, 30), LEN(LEFT(Part.Description, 30)) - CHARINDEX(' ', REVERSE(LEFT(Part.Description, 29)))) </span><span style="color:rgb(0, 0, 0);">)</span> AS , <span style="color:rgb(0, 0, 0);">IIF(LEN(Part.Description) &lt; 30, </span><span style="color:rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:rgb(0, 0, 0);">'', </span><span style="color:rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:rgb(0, 0, 0);">Substring(LEFT(Part.Description, 60), </span><span style="color:rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color:rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp; </span><span style="color:rgb(0, 0, 0);">1+(LEN(LEFT(Part.Description, 30)) - CHARINDEX(' ', REVERSE(LEFT(Part.Description, 29)))), 30)</span><span style="color:rgb(0, 0, 0);">) AS FROM SCHEMA.YOURTABLE</span></li></ul></li><li><b>REMOVE ALPHAS FROM STRINGS</b><ul><li>STUFF(YOURCOLUMN, PATINDEX('%%', YOURCOLUMN)-1, '')</li></ul></li></ul><h2>C#</h2><ul><li><strong>DateTime type to Formatted String:</strong> String.Format(&quot;{0:M/d/yyyy}&quot;, callContextBpmData.Date01)</li><li><strong>Seconds (Integer) to short time formatted string:</strong> TimeSpan.FromSeconds(42200).ToString(&quot;t&quot;)</li></ul> I am finding that the C# ToString() and String.Format() usage scope within Epicor to be quite baffling.&nbsp; Not sure when to use which and many of the documentation sites are not very helpful in clearing this up.&nbsp; Maybe I'll get it some day. Somewhat helpful ink:&nbsp; <a href="http://www.csharp-examples.net/string-format-datetime/">http://www.csharp-examples.net/string-format-datetime/</a></div></div>
</div></div></div></div></div></div> ]]></content:encoded><pubDate>Tue, 29 Nov 2016 22:48:04 -0500</pubDate></item></channel></rss>