There is an application where I have some data, and that data has a date( for ex: start date), I need to change that date to beggining of next month every time I login to that application
Can you below:
DateTime.Now.AddMonths(1) Gives you the next month
DateTime.Now.Day=1, Try this
Try with this below expression
DateTime.Now.AddMonths(1).tostring("MM/dd/yyyy")
Regards
Gokul
Hi @ayushi_jain3
Follow the below steps to achieve required output.
- Store the extracted date from an application in a variable, say “currentDateText”.
- Use Assign activity create an variable say “currentDate” and datatype is System.DateTime and Write the below syntax:
currentDate=DateTime.ParseExact(currentDateText,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture)
- Use an Assign activity create an variable say “nextMonthDate” of datatype String and write the below syntax:
nextMonthDate=currentDate.AddMonths(1).Date.AddDays(-currentDate.Day + 1)
- The above syntax will give first day of the next month.
- Perform further actions in the application using the updated date.
Note: See sample workflow for reference.
Sequence.xaml (8.8 KB)
Hope it helps!!
Regards,
Hi Guyys, thanks for the quick solutions, but my first step was to extract date from an application and I am unable to do that. Post that I need to change the date.
@ayushi_jain3 show use where do you want to get. Use get text activity
This is the data in the application, what i need to do is, pick that date, change it to beginning of next month and then run the next steps. I would really appreciate if I have the solution for extracting the date part and the changing it to beginning of next month
@ayushi_jain3 is it Json file?
Yes, It’s JSON
@ayushi_jain3 for that you need to Deserialize the json file and then go by indexing to exact value.
you will get date in string then convert date to datetime and change it
Could you please provide the xaml file for this process. Haven’t worked on json file earlier so unable to understand the steps
@ayushi_jain3 share json file if data is not confidential
{
“fields”: [
“CompanyEIN_MasterTax_CompanyId”,
“CompShortName”,
“CompName”,
“CompTax_JurisdictionType”,
“CompTax_StateName”,
“CompTax_TaxType”,
“CompTax_Name”,
“CompTax_Description”,
“TaxFamily_TaxDescription”,
“CompTax_StateLocalEINToShow”,
“CompanyEIN_MasterTax_StartDate”,
“CompanyEIN_MasterTax_EndDate”,
“CompLocked”,
“CurrentStatus”,
“CompTax_IsIgnoreMasterTax”,
“CompTax_MasterTax_EETaxCode”,
“CompTax_MasterTax_EETaxCode_NonRes”,
“CompTax_MasterTax_ERTaxCode”,
“CompPrimaryContactPrimaryEmail”,
“CompPRContactPrimaryEmail”
],
“filters”: [
{
“field_name”: “CompShortName”,
“operator”: “!”,
“values”: [
“test”
]
},
{
“field_name”: “CompanyEIN_MasterTax_CompanyId”,
“operator”: “!is_null”,
“values”:
},
{
“field_name”: “CompName”,
“operator”: “",
“values”: [
“”
]
},
{
“field_name”: “CompTax_JurisdictionType”,
“operator”: "”,
“values”: [
“”
]
},
{
“field_name”: “CompTax_StateName”,
“operator”: “",
“values”: [
“”
]
},
{
“field_name”: “CompTax_TaxType”,
“operator”: "”,
“values”: [
“”
]
},
{
“field_name”: “CompTax_Name”,
“operator”: “",
“values”: [
“”
]
},
{
“field_name”: “CompTax_Description”,
“operator”: “=”,
“values”: [
“”
]
},
{
“field_name”: “TaxFamily_TaxDescription”,
“operator”: "”,
“values”: [
“”
]
},
{
“field_name”: “CompTax_StateLocalEINToShow”,
“operator”: “",
“values”: [
“applied”
]
},
{
“field_name”: “CompanyEIN_MasterTax_StartDate”,
“operator”: “<”,
“values”: [
“04/01/2023”
]
},
{
“field_name”: “CompanyEIN_MasterTax_EndDate”,
“operator”: “=”,
“values”: [
“”
]
},
{
“field_name”: “CompLocked”,
“operator”: “is”,
“values”: [
“No”
]
},
{
“field_name”: “CurrentStatus”,
“operator”: “=”,
“values”: [
“”
]
},
{
“field_name”: “CompTax_IsIgnoreMasterTax”,
“operator”: “is”,
“values”: [
“No”
]
},
{
“field_name”: “CompTax_MasterTax_EETaxCode”,
“operator”: "”,
“values”: [
“”
]
},
{
“field_name”: “CompTax_MasterTax_EETaxCode_NonRes”,
“operator”: “",
“values”: [
“”
]
},
{
“field_name”: “CompTax_MasterTax_ERTaxCode”,
“operator”: "”,
“values”: [
“”
]
},
{
“field_name”: “CompPrimaryContactPrimaryEmail”,
“operator”: “=”,
“values”: [
“”
]
},
{
“field_name”: “CompPRContactPrimaryEmail”,
“operator”: “=”,
“values”: [
“”
]
}
],
“orders”: [
{
“is_descending”: false,
“field_name”: “CompShortName”
},
{
“is_descending”: false,
“field_name”: “CompTax_JurisdictionType”
},
{
“is_descending”: false,
“field_name”: “CompTax_StateName”
},
{
“is_descending”: false,
“field_name”: “CompTax_Name”
}
],
“selectors”: [
{
“type”: “CheckedOptions”,
“name”: “ShowOptions”,
“parameters”: {
“ShowEINMissingOrAppliedFor”: “0”
}
}
]
}
@ayushi_jain3 which field do you want to get?
@ayushi_jain3 can you attach “json” file here instead of sharing like this
It looks like you are using a api in postman…we have activity http request which can be used for triggering api and get the response directly instead of using postman
and the we can go with deserialize and looks like jarray so can use a loop to check what you need and get the details
so first try using http request activity for that install UiPath.webapi.activities
according to structure after deserializing the value can be obtained like this output("filters")(6)("values")(0).ToString
the value 6 needs to be changed or need to use loop to check according to what value you want to extract
cheers
if you need to use that as a String somewhere else:
DateTime.ParseExact(startDate,“MM/dd/yyyy”, Globalization.CultureInfo.InvariantCulture).AddMonths(1).toString(“MM/01/yyyy”)
Change the format accordingly.
Post Deserializing the JSON, find the index of fieldName using counts and checking against CompanyEIN_MasterTax_StartDate.
Once you have the count, you can retrieve it.
or else lets say that you have this response in a variable called ResponseContent.
System.Text.RegularExpressions.Regex.Replace(ResponseContent.Split({“CompanyEIN_MasterTax_StartDate”},StringSplitOptions.None)(1).Split({“values”},StringSplitOptions.None)(1).Split({“]”},StringSplitOptions.None)(0), “[^\w/]”, “”).ToString
Thanks,
Happy Automation!
how are you doing am bless nice meeting you here