<?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 I need help with Get in Community Central forum</title>
    <link>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061125#M1002</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Função para formatar a data no padrão que a API espera (YYYY-MM-DD HH:mm:ss)
const formatDate = (date: Date): string =&amp;gt; {
    return format(date, 'yyyy-MM-dd HH:mm:ss');
  };

// Pegando o início e o fim do dia atual (meia-noite até 23:59:59)
const inicioDia = startOfDay(new Date()); // Meia-noite de hoje
const fimDia = endOfDay(new Date());     // 23:59:59 de hoje
console.log(inicioDia,fimDia)
// Formate as datas
const startDia = formatDate(inicioDia);  // Meia-noite de hoje
const endDia = formatDate(fimDia);      // 23:59:59 de hoje

// Crie a query combinada (busca por `opened_at` ou `sys_updated_on` no dia de hoje)
const betweenOpenedAt = `opened_atBETWEEN${startDia}@${endDia}`;
const betweenUpdatedAt = `sys_updated_onBETWEEN${startDia}@${endDia}`;
const betweenCloseAT = `closed_atBETWEEN${startDia}@${endDia}`
// Comando que combina as duas condições com OR
//const dateQuery = `${betweenOpenedAt}^OR${betweenUpdatedAt}^OR${betweenCloseAT}`;
const dateQuery = `${betweenOpenedAt}`;
console.log(dateQuery)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I'm creating a URL to retrieve data from the Incident table, and I want everything that was created, updated or closed on the current day (today).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt; The date format I'm returning is this: &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;opened_atBETWEEN2024-10-01 00:00:00@2024-10-01 23:59:59 &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;But for some reason I'm retrieving data from yesterday too, and I only want today's data. Can anyone help me?&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;My URL is like this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export const urlIncident = `${baseUrlIncident}?sysparm_query=${dateQuery}^${orderby}&amp;amp;${limit}`;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2024 12:40:07 GMT</pubDate>
    <dc:creator>Arthur Sanchez</dc:creator>
    <dc:date>2024-10-01T12:40:07Z</dc:date>
    <item>
      <title>I need help with Get</title>
      <link>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061125#M1002</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Função para formatar a data no padrão que a API espera (YYYY-MM-DD HH:mm:ss)
const formatDate = (date: Date): string =&amp;gt; {
    return format(date, 'yyyy-MM-dd HH:mm:ss');
  };

// Pegando o início e o fim do dia atual (meia-noite até 23:59:59)
const inicioDia = startOfDay(new Date()); // Meia-noite de hoje
const fimDia = endOfDay(new Date());     // 23:59:59 de hoje
console.log(inicioDia,fimDia)
// Formate as datas
const startDia = formatDate(inicioDia);  // Meia-noite de hoje
const endDia = formatDate(fimDia);      // 23:59:59 de hoje

// Crie a query combinada (busca por `opened_at` ou `sys_updated_on` no dia de hoje)
const betweenOpenedAt = `opened_atBETWEEN${startDia}@${endDia}`;
const betweenUpdatedAt = `sys_updated_onBETWEEN${startDia}@${endDia}`;
const betweenCloseAT = `closed_atBETWEEN${startDia}@${endDia}`
// Comando que combina as duas condições com OR
//const dateQuery = `${betweenOpenedAt}^OR${betweenUpdatedAt}^OR${betweenCloseAT}`;
const dateQuery = `${betweenOpenedAt}`;
console.log(dateQuery)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I'm creating a URL to retrieve data from the Incident table, and I want everything that was created, updated or closed on the current day (today).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt; The date format I'm returning is this: &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;opened_atBETWEEN2024-10-01 00:00:00@2024-10-01 23:59:59 &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;But for some reason I'm retrieving data from yesterday too, and I only want today's data. Can anyone help me?&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;My URL is like this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export const urlIncident = `${baseUrlIncident}?sysparm_query=${dateQuery}^${orderby}&amp;amp;${limit}`;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 12:40:07 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061125#M1002</guid>
      <dc:creator>Arthur Sanchez</dc:creator>
      <dc:date>2024-10-01T12:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with Get</title>
      <link>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061134#M1003</link>
      <description>&lt;P&gt;The timezone of your executed query will be based on the user's timezone of the account you're using to authenticate with ServiceNow. Possibly this user record is in a different timezone to the instance and therefore the query is extending into a bigger window than you realise?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 12:50:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061134#M1003</guid>
      <dc:creator>Kieran Anson</dc:creator>
      <dc:date>2024-10-01T12:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with Get</title>
      <link>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061137#M1004</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;It is possible, and maybe that is it, but what I want to know is, is my BETWEEN field correct?&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;In terms of date/time?&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Because if this format is not correct I need to know how to solve it.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 12:53:29 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061137#M1004</guid>
      <dc:creator>Arthur Sanchez</dc:creator>
      <dc:date>2024-10-01T12:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with Get</title>
      <link>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061145#M1005</link>
      <description>&lt;P&gt;Yes your format is correct&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;opened_atBETWEENjavascript&amp;amp;colon;gs.beginningOfToday()@javascript&amp;amp;colon;gs.endOfToday()&lt;/P&gt;
&lt;P&gt;Translates to:&lt;/P&gt;
&lt;P&gt;opened_atBETWEEN2024-09-30 23:00:00@2024-10-01 22:59:59&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 12:58:18 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061145#M1005</guid>
      <dc:creator>Kieran Anson</dc:creator>
      <dc:date>2024-10-01T12:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with Get</title>
      <link>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061160#M1006</link>
      <description>&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Dude, if my date/time format is correct, what can I do to try to get the data based on the correct result, to get only what was done today based on my time?&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I don't know what the time zone is of the instance from where I'm getting the GET from. I didn't create the instance, it's from my work.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 13:10:47 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061160#M1006</guid>
      <dc:creator>Arthur Sanchez</dc:creator>
      <dc:date>2024-10-01T13:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with Get</title>
      <link>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061209#M1007</link>
      <description>&lt;P&gt;Do you not have a ServiceNow admin who can tell you? If you send the following query, do you get unexpected results? Below is the default time filter for "Today"&lt;/P&gt;
&lt;P&gt;opened_atONToday@javascript&amp;amp;colon;gs.beginningOfToday()@javascript&amp;amp;colon;gs.endOfToday()&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 13:40:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061209#M1007</guid>
      <dc:creator>Kieran Anson</dc:creator>
      <dc:date>2024-10-01T13:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with Get</title>
      <link>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061212#M1008</link>
      <description>&lt;P&gt;&lt;SPAN&gt;No man, what happens is, my work has a demand for servicenow, so I need to extract the data from the endpoint that was given to me, collecting the data from "today", every day, that's all I know, and I'm doing everything through JS in vsccode&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 13:43:11 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061212#M1008</guid>
      <dc:creator>Arthur Sanchez</dc:creator>
      <dc:date>2024-10-01T13:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: I need help with Get</title>
      <link>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061271#M1013</link>
      <description>&lt;LI-CODE lang="javascript"&gt;// Crie a query combinada (busca por `opened_at`, `sys_updated_on` ou `closed_at` no dia de hoje)
const betweenOpenedAt = `opened_atBETWEENjavascript&amp;amp;colon;gs.dateGenerate('${startDia}')@javascript&amp;amp;colon;gs.dateGenerate('${endDia}')`;
const betweenUpdatedAt = `sys_updated_onBETWEENjavascript&amp;amp;colon;gs.dateGenerate('${startDia}')@javascript&amp;amp;colon;gs.dateGenerate('${endDia}')`;
const betweenClosedAt = `closed_atBETWEENjavascript&amp;amp;colon;gs.dateGenerate('${startDia}')@javascript&amp;amp;colon;gs.dateGenerate('${endDia}')`;
// Comando que combina as duas condições com OR
const dateQuery = `${betweenOpenedAt}^OR${betweenUpdatedAt}^OR${betweenClosedAt}`;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;I THINK IT'S SOLVED, I asked chatgpt to help me and he fixed the url, I tested it in postman and it's ok&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/431446"&gt;@Kieran Anson&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 14:29:16 GMT</pubDate>
      <guid>https://www.servicenow.com/community/community-central-forum/i-need-help-with-get/m-p/3061271#M1013</guid>
      <dc:creator>Arthur Sanchez</dc:creator>
      <dc:date>2024-10-01T14:29:16Z</dc:date>
    </item>
  </channel>
</rss>

