<?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 compare end date and start date in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/compare-end-date-and-start-date/m-p/3055738#M968</link>
    <description>&lt;P&gt;Hello, I have a requirement for the Record Producer. There are two variables: "&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;Proposed Effective Date&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;" and "&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;Expected End Date&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;," both of which are of the "Date" type variable.&lt;/P&gt;&lt;P&gt;1)Requirement is that the "&lt;FONT color="#FF0000"&gt;Expected End Date&lt;/FONT&gt;" must be &lt;FONT color="#FF0000"&gt;greater than&lt;/FONT&gt; the "&lt;FONT color="#FF0000"&gt;Proposed Effective Date.&lt;/FONT&gt;" If this condition is not met:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Clear the value of "Expected End Date" whenever the "Proposed Effective Date" is changed.&lt;/LI&gt;&lt;LI&gt;Display the error message: "Expected End Date is smaller than Proposed Effective Date."&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Wed, 25 Sep 2024 13:14:48 GMT</pubDate>
    <dc:creator>Community Alums</dc:creator>
    <dc:date>2024-09-25T13:14:48Z</dc:date>
    <item>
      <title>compare end date and start date</title>
      <link>https://www.servicenow.com/community/community-central-forum/compare-end-date-and-start-date/m-p/3055738#M968</link>
      <description>&lt;P&gt;Hello, I have a requirement for the Record Producer. There are two variables: "&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;Proposed Effective Date&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;" and "&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;Expected End Date&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;," both of which are of the "Date" type variable.&lt;/P&gt;&lt;P&gt;1)Requirement is that the "&lt;FONT color="#FF0000"&gt;Expected End Date&lt;/FONT&gt;" must be &lt;FONT color="#FF0000"&gt;greater than&lt;/FONT&gt; the "&lt;FONT color="#FF0000"&gt;Proposed Effective Date.&lt;/FONT&gt;" If this condition is not met:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Clear the value of "Expected End Date" whenever the "Proposed Effective Date" is changed.&lt;/LI&gt;&lt;LI&gt;Display the error message: "Expected End Date is smaller than Proposed Effective Date."&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Wed, 25 Sep 2024 13:14:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/compare-end-date-and-start-date/m-p/3055738#M968</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-09-25T13:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: compare end date and start date</title>
      <link>https://www.servicenow.com/community/community-central-forum/compare-end-date-and-start-date/m-p/3055782#M969</link>
      <description>&lt;P&gt;You have two option for the comparison of dates.&lt;/P&gt;
&lt;P&gt;1. &lt;A href="https://www.servicenow.com/community/developer-articles/no-code-date-validations-through-catalog-ui-policies/ta-p/2297600" target="_blank" rel="noopener"&gt;No Code Data compare UI Policy&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;2. &lt;A href="https://www.servicenow.com/community/in-other-news/auto-populating-and-validating-date-fields/ba-p/2268163" target="_blank" rel="noopener"&gt;Script Include with client scripts&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;As for Clearing Expected End Date you could try doing that in a client script but know that you cannot see the previous value to verify that it was actually changed.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 13:40:17 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/compare-end-date-and-start-date/m-p/3055782#M969</guid>
      <dc:creator>brianlan25</dc:creator>
      <dc:date>2024-09-25T13:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: compare end date and start date</title>
      <link>https://www.servicenow.com/community/community-central-forum/compare-end-date-and-start-date/m-p/3055803#M972</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Community Alums&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Create a script include:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script Include name: DateTimeUtils&lt;/P&gt;&lt;P&gt;client callable: true&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var DateTimeUtils = Class.create();
DateTimeUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
 compareEndDate: function() {
        var check = false;
        var startDate = this.getParameter('sysparm_start_date');
        var endDate = this.getParameter('sysparm_end_date');
        var gdt1 = new GlideDateTime(startDate);
        var gdt2 = new GlideDateTime(endDate);
        check = gdt1.before(gdt2);
        return check;
    },
    type: 'DateTimeUtils'
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Create a client script onchange of proposed effective date&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
var startdate = g_form.getValue('expected_end_date');//change the variable name
	if(startdate == '')
		{
			g_form.clearValue('proposed_effective_Date');//change the variable name
			g_form.showFieldMsg('proposed_effective_Date','Please select Expected end date first date first','error');/change the variable name			
			return;
		}
	else
		{
			var ga = new GlideAjax('global.DateTimeUtils');
			ga.addParam('sysparm_name','compareEndDate');
			ga.addParam('sysparm_start_date',startdate);
			ga.addParam('sysparm_end_date',newValue);
			ga.getXML(responseCallBack);
		}  
	function responseCallBack(response)
	{
		var ans = response.responseXML.documentElement.getAttribute('answer');
		if(ans== false || ans == 'false')
			{
				g_form.clearValue('proposed_effective_Date');//change the variable name
				g_form.showFieldMsg('proposed_effective_Date','Please select a future date','error');/change the variable name
				
			}
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 13:51:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/compare-end-date-and-start-date/m-p/3055803#M972</guid>
      <dc:creator>KrishnaSwaA</dc:creator>
      <dc:date>2024-09-25T13:51:28Z</dc:date>
    </item>
  </channel>
</rss>

