Hi ,
Im trying to filtrer data table based on Date to get current month data only. Can someone help me in writting Dt.select() for it.
screenshot has date format
Hi @Raj_Kumar1
Dt.Select(“Started '” & DateTime.now.ToString(“MM”) & "’ ").CopyToDataTable
Hope this helps you!!!
Good day
Hi Shubham,
Thanks for the quick response. Im new to .net and uipath. can you just tell me whats happening inside dt.select() ?? what is ‘&’ for?
By the way Date format is “MM/DD/YYYY”
Dt.select() that you wrote has some syntactical error. I was trying to correct it but as i told you i’m new to .net and uipath i could not.
Hi @Raj_Kumar1
Pass me your XAML file, let me correct it for you!!!
The date format is in “MM/DD/YYYY” though if we want date from current month it’s with “MM”
& is to pass the date in a variable, saying so I understood what was wrong in my query
dt.Select(“Started = ’ DateTime.now.ToString(“MM”) ’ ").CopyToDataTable
If it’s still erring pass me the whole project, I’ll get it sorted
yah the condition should be like this
–use a assign activity and create a variable like this
in_date = New DateTime(now.year,now.month,1)
then another assign activity like this
DT = DT.Select("[yourcolumnname] > ’ # + in_date.ToString + # ’ ").CopyToDatatable()
here
yourcolumnname = the columnname here is Started
in_date = The variable that stores the first day of the current month
hope this would help you
Cheers @Raj_Kumar1
Sequence.xaml (10.8 KB)
Input file is of type CSV … I Could not upload it.
Wasn’t able to test it, but try using the following:
Create a month variable with DateTime.now.ToString(“MM”)
DT.Select("[Started] = ’ # + month.toString + # ’ ").CopyToDatatable()
Or
dt.Select(“[Started] = '” & Month.tostring & "’ ").CopyToDataTable
@Raj_Kumar1 the select query can be used to overwrite on original data base as well!!!
It’s just getting the date sorted out!!! Hope this helps
Hi @Palaniyappan For my Excel the queries is not working. Could you please help how to figure it out? I need to filter out the current month date.
I have used two ways
1)OutputDT.select(“[CA Agreed Completion Date] ='”+DateTime.Now.Month.ToString ).CopytoDatatable
2) Using filter wizard activity → “Column Name” Contains "DateTime.Now.ToString (“MM/yyyy”)
I have declared “CA Agreed Completion Date” as Datetime in buildtable activity.