Get the date , month , Year from get text in different format

I am copying the same but dont know why. let me retry.

Hey ,

This is giving correct. 10/29/2022 00:00:00. But I just want the date not time.

Finally :smiley:
This is datetime type.
If you want year, add .Year to this expression, if you want month use .Month, for day you have .Day method:

DateTime.ParseExact(Variable.Split(":".ToCharArray)(1).ToString.Trim,"MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture).Year
DateTime.ParseExact(Variable.Split(":".ToCharArray)(1).ToString.Trim,"MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture).Month
DateTime.ParseExact(Variable.Split(":".ToCharArray)(1).ToString.Trim,"MMM dd, yyyy",Globalization.CultureInfo.InvariantCulture).Day

Or to make code prettier assign your expression to DateTime variable and use:

DateTimeVariable.Year
DateTimeVariable.Month
DateTimeVariable.Day

To type somewhere date in specific format there is method:

DateTimeVariable.ToString("whatever format you want")

few examples:
Capture

Thanks but not getting it. How to do that ? I have Variable 1 which is giving me value 10/29/2022 00:00:00.

dateTimeVariable.Month and dateTimeVariable.Year gives you numbers (integers) which you can use in comparison. That was our goal?

Want this
image
to enter here on my web portal : Ex:
image

But actual goal is to check reports for dates less than 29 . not more than that EX: Today is 31 then I have to check first this on website If it says reports update through 29 then I have to check 29 date report only .

Currently checking 31, 30, 29 : IF not available then it will show on webpage but the new update will not show that it will show “Report Updated: Oct 29, 2022” this status.

^^ Hi
Um… I used two method Datetime, DateAdd. so I get -3 Days at Every Month.

Step 1. Get this Month First Day
String sThisMonthFirstDay = Datetime.Now.ToString(“yyyy-MM”) + “-1”

Step 2. Get before 3 days for this month first day!
DateAdd(“d”, -1, sThisMonthFirstDay).ToString(“yyyy-MM-dd”)
DateAdd(“d”, -2, sThisMonthFirstDay).ToString(“yyyy-MM-dd”)
DateAdd(“d”, -3, sThisMonthFirstDay).ToString(“yyyy-MM-dd”)

I hope help you.

Thank you.

Can someone help here to get the date here as shown in screenshot ? @Konrad_Mierzwa if you can help me here to get the date part ? I used your entire code so thinking that you can help here.

Hi,

Thanks for suggestion.
I am actually getting Date with time but I just want date so, just help me through that if you can . I am using the c ode which @Konrad_Mierzwa suggested in the thread.
Let me know if yo need further information.

It is ok to have time in dateTime variable, do not worry about that :slight_smile:
Because you can define any format you want.
Look at this:
typing variable with time:
image
typing the same variable with date only:
image
typing only year:
image
We have even millisecond and ticks hidden somewhere in the same variable :wink: :
image

So if you want to type date without time in website just use

dateTimeVariable.ToString("MM/dd/yyyy")

in type into activity

1 Like

Hi.
Um… You can see the Date for the Log Message Activity and I send to a sample code.

  1. This Month Last Day
    DateAdd(“d”, -1, DateAdd(“m”, 1, Now.ToString(“yyyy-MM”))).ToString(“MM/dd/yyyy”)

  2. This Month Last 2 Days
    DateAdd(“d”, -2, DateAdd(“m”, 1, Now.ToString(“yyyy-MM”))).ToString(“MM/dd/yyyy”)

  3. This Month Last 3 Days
    DateAdd(“d”, -3, DateAdd(“m”, 1, Now.ToString(“yyyy-MM”))).ToString(“MM/dd/yyyy”)

if you can see the youtube. My introduce youtube channel and you will look my lecture for DateTime manipulation.

Youtube : DateTime Manipulation

Good Luck.

Getting below error . FYI - Getting Website text in string Variable.
image

Thanks but I don’t want month’s last days . I want to convert my string to standard date format. Can you help me into that part ?

You were told how to do that in the very first reply. Datetime.ParseExact…

But I don’t know why , this error coming.
image

@PALKUMARI_PATEL
DateTime.Parse(dateString, system.globalization.cultureInfo) this would convert it to date

Compiler error . Can you try with this string variable ?
image

@PALKUMARI_PATEL

1 Like

You have to tell it how to parse the string. That’s what the second parameter is, the format of the string so it knows which part is the month, day, year etc.

Datetime.ParseExact(“Dec 4, 2022”,“MMM d, yyyy”,System.Globalization.CultureInfo.InvariantCulture)

image

Here is info about the format identifiers…

1 Like

Thanks Got the answer.