# Quick Guidance Please

**URL:** <https://forum.uipath.com/t/quick-guidance-please/413757>\
**Category:** Academic Alliance\
**Tags:** linq-query, academic-alliance, question, studio, excel, activities\
**Created:** [April 8, 2022, 2:51pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757 "2022-04-08T14:51:47Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sudharsan\_Ka](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sudharsan_ka/32/459826_2.png) [@Sudharsan\_Ka](https://forum.uipath.com/u/Sudharsan_Ka)\
**Post date:** [April 8, 2022, 2:51pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/1 "2022-04-08T14:51:47Z")

</div>

Hi All

I have used this query to return the rows but no values are returning in the output of this  
dt.AsEnumerable().Where (Function(D) DateTime.ParseExact(D(“Data validarii CN”).ToString,“yyyy-MM-dd HH:mm:ss”,CultureInfo.InvariantCulture).ToString(“MM”) = now.AddMonths(-1).ToString(“MM”)).CopyToDataTable

So the task is to get filter only the rows which are in the date of currentMonth -1

Here is the input.

@ashwin.ashok @ppr @Yoichi  
[input.xlsx](https://forum.uipath.com/uploads/short-url/cHMWcTjPtMqhJrIep8Y0mN0C9cH.xlsx) (106.4 KB)

Regards  
Sudharsan

---

<div class="post-metadata">

**Author:** ![Nithinkrishna](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nithinkrishna/32/561519_2.png) [@Nithinkrishna](https://forum.uipath.com/u/Nithinkrishna)\
**Post date:** [April 8, 2022, 3:08pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/2 "2022-04-08T15:08:00Z")

</div>

> [@Sudharsan\_Ka](#):
>
> dt.AsEnumerable().Where (Function(D) DateTime.ParseExact(D(“Data validarii CN”).ToString,“yyyy-MM-dd HH:mm:ss”,CultureInfo.InvariantCulture).ToString(“MM”) = now.AddMonths(-1).ToString(“MM”)).CopyToDataTable

Hey @Sudharsan_Ka

Kindly try this statement,

```auto
dt.AsEnumerable().Where (Function(D) DateTime.ParseExact(D("Data validarii CN").ToString,{"yyyy-MM-dd HH:mm:ss","MM/dd/yyyy HH:mm:ss"},Globalization.CultureInfo.InvariantCulture,Nothing).ToString("MM") = now.AddMonths(-1).ToString("MM")).CopyToDataTable

```

I was checking the input sheet and last row date was in custom format due to some reason (may be a manual error)

Either you need to update code as above or make the excel format proper.

Hope this helps.

Thanks  
#nK

---

<div class="post-metadata">

**Author:** ![Sudharsan\_Ka](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sudharsan_ka/32/459826_2.png) [@Sudharsan\_Ka](https://forum.uipath.com/u/Sudharsan_Ka)\
**Post date:** [April 8, 2022, 3:11pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/3 "2022-04-08T15:11:00Z")

</div>

it throws source contains no row error in the expression @Nithinkrishna

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [April 8, 2022, 3:12pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/4 "2022-04-08T15:12:00Z")

</div>

> [@Sudharsan\_Ka](#):
>
> dt.AsEnumerable().Where (Function(D) DateTime.ParseExact(D(“Data validarii CN”).ToString,“yyyy-MM-dd HH:mm:ss”,CultureInfo.InvariantCulture).ToString(“MM”) = now.AddMonths(-1).ToString(“MM”)).CopyToDataTable

lets rewrite to Query syntax and do checking on month instead of string base

```auto
(From d in dt.AsEnumerable()
let dp = DateTime.ParseExact(d("Data validarii CN").toString.Trim,“yyyy-MM-dd HH:mm:ss”,CultureInfo.InvariantCulture)
Where dp.Month = now.AddMonths(-1).Month
Select r=d).CopyToDataTable

```

But when your data is away from last month so result is empty

Also have alook here:

> [@ambulance sos \[FirstAid\] Handling of The source contains no DataRows exception](https://forum.uipath.com/t/firstaid-handling-of-the-source-contains-no-datarows-exception/410526):
>
> This FirstAid Tutorial will describe how a the source contains no DataRows EXCEPTION can be handled. Introduction Let’s have a look at the following filter data table scenario: Name CCode Tom US Charlotte FR Seema IN Jean FR Assignment: Filter all rows on a particular Country Code like FR, UK, ES, UK… Ensure that all CCode data column values are trimmed Ensure that the Filter check is case insensitive we can implement it e.g. with the help of a LINQ statement: dtData.AsE…

---

<div class="post-metadata">

**Author:** ![Nithinkrishna](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nithinkrishna/32/561519_2.png) [@Nithinkrishna](https://forum.uipath.com/u/Nithinkrishna)\
**Post date:** [April 8, 2022, 3:12pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/5 "2022-04-08T15:12:31Z")

</div>

Hey @Sudharsan_Ka

Is your variables right please check, I have used my own test var.

Thanks  
#nK

---

<div class="post-metadata">

**Author:** ![Sudharsan\_Ka](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sudharsan_ka/32/459826_2.png) [@Sudharsan\_Ka](https://forum.uipath.com/u/Sudharsan_Ka)\
**Post date:** [April 8, 2022, 3:13pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/6 "2022-04-08T15:13:08Z")

</div>

yes it is @Nithinkrishna

---

<div class="post-metadata">

**Author:** ![Nithinkrishna](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nithinkrishna/32/561519_2.png) [@Nithinkrishna](https://forum.uipath.com/u/Nithinkrishna)\
**Post date:** [April 8, 2022, 3:14pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/7 "2022-04-08T15:14:18Z")

</div>

Hey @Sudharsan_Ka

Check my run please,

 ![image](https://global.discourse-cdn.com/uipath/original/4X/3/7/4/374ea2fd56f61f38d7c2a44f3528c910b4180cc5.png)

I’m just using the same query which I posted above. _(Just updated it as per my data table variable)_

Thanks  
#nK

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [April 8, 2022, 3:17pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/8 "2022-04-08T15:17:40Z")

</div>

> [@ppr](#):
>
> `Where dp.Month = now.AddMonths(-1).Month`

For a more reliable check over the years also have a look on following filter strategy:

```auto
Where dp.toString("yyyy-MM").Equals(now.AddMonths(-1).toString("yyyy-MM"))

```

---

<div class="post-metadata">

**Author:** ![Sudharsan\_Ka](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sudharsan_ka/32/459826_2.png) [@Sudharsan\_Ka](https://forum.uipath.com/u/Sudharsan_Ka)\
**Post date:** [April 8, 2022, 3:18pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/9 "2022-04-08T15:18:16Z")

</div>

Now it is returning empty string @Nithinkrishna @ppr

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [April 8, 2022, 3:20pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/10 "2022-04-08T15:20:52Z")

</div>

> [@Sudharsan\_Ka](#):
>
> Now it is returning empty string

such a case just debug and inspect the datatable content (this counts, not the excel)  
[Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum](https://forum.uipath.com/t/understanding-the-6-debugging-panels-of-uipath-in-the-easiest-way-possible/353606)

it could be tha case that different Date formats will be present within the datatable after read range. Just check this also

---

<div class="post-metadata">

**Author:** ![Sudharsan\_Ka](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sudharsan_ka/32/459826_2.png) [@Sudharsan\_Ka](https://forum.uipath.com/u/Sudharsan_Ka)\
**Post date:** [April 8, 2022, 3:27pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/11 "2022-04-08T15:27:06Z")

</div>

I am too sorry for the wasting your time @Nithinkrishna @ppr it’s my f… blender mistake in a hurry.

The Linq i shared it self printing the values. i have passed the wrong variable to print in the message box

Anyway thanks both of you for sharing your ideas

Regards  
Sudharsan

---

<div class="post-metadata">

**Author:** ![Nithinkrishna](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nithinkrishna/32/561519_2.png) [@Nithinkrishna](https://forum.uipath.com/u/Nithinkrishna)\
**Post date:** [April 8, 2022, 5:21pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/12 "2022-04-08T17:21:59Z")

</div>

Cool @Sudharsan_Ka 🙂👍

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [April 11, 2022, 5:22pm UTC](https://forum.uipath.com/t/quick-guidance-please/413757/13 "2022-04-11T17:22:33Z")

</div>

Closed on April 11, 2022, 5:22pm UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
