How to get a sheet name and convert it a datetime format?

Hi,
I have an excel sheet named like 03.11.2022 I want to take this name as datetime and write to first and last day of this date in a webpage.
For example if the sheet name is 03.11.2022 then I want to write 01.11.2022 and 30.11.2022.
Thank you.

Hello @makboga

You can use the Getsheet method to get the sheetnames. Please check the below psot. Then to get the first date of the month, you can use the modify date activity.

Hi @makboga

After doing get sheets you will have sheet name

Now for first date use “01.” + date.ParseExact(“yourdate”,”dd.MM.yyyy”,system.globalization.culturalinfo.invariantculture).tostring(“MM.yyyy”)

For last date daysinmonth(Cint(yourdate.split(“.”c)(1)), Cint(yourdate.split(“.”c)(2)))+ date.ParseExact(“yourdate”,”dd.MM.yyyy”,system.globalization.culturalinfo.invariantculture).tostring(“MM.yyyy”)

Cheers

I used get sheets and get the sheet name but when I convert sheetname to datetime it gives me US format as 11.03.2022 but I want European format. How can I fix this?

HI @makboga

How about this expression?

Get Only the Month from the Input

DateTime.ParseExact(yourString,"dd.MM.yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("MM")

First Date

New DateTime(Now.Year,CInt(GetMonth),1).ToString("dd-MM-yyyy")

Last Date

New DateTime(Now.Year,CInt(GetMonth)+1,1).AddDays(-1).ToString("dd-MM-yyyy")

Check out the XAML file

FirstandLastDate.xaml (6.3 KB)

image

Regards
Gokul

1 Like

I am getting this error

Hi @makboga

Have you check my XAML file.

You have to Declare the GetMonth

Check out the Screenshot

It worked thank you so much.

1 Like

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