To get Date from Month

Hello guys i have a input dialog box to select Month

t

I want to get the starting and ending Date for the selected month.

@Gokul_Murali

for first day just add 1 and the year as you need

once you get that the first date use cdate(date).Addmonths(1).AddDays(-1).ToString("MM/dd/yyyy")

cheers

Hi @Gokul_Murali

Try this way

First convert → MMMM to MM

var string monthNumber = DateTime.ParseExact(monthName, "MMMM", System.Globalization.CultureInfo.InvariantCulture).ToString("MM")

var datetime startDate = New DateTime(selectedYear, selectedMonth, 1)

var datetime endDate = startDate.AddMonths(1).AddDays(-1)

Here selectedYear, and selectedMonth variable type is integer

Regards,
Gowtham K

Hi @Gokul_Murali

I have attached the workflow below,

Main.xaml (16.4 KB)


@pradeep931

Bro this file showing invalid

@Gokul_Murali

Please check again, i have converted to zip

SelectedDate.zip (152.7 KB)

@pradeep931

Again it look invalid

Main.xaml (16.4 KB)
Could you please try this

@pradeep931

Again the same brother

HI,

Can you share what version of Studio you use?

Also, share information about which year we should use?

Regards,

@Yoichi

Studio version is 22.4.3

@Gowtham_K115

Here i have declared (monthNumber) variable.

In ( startDate) variable What is this selectedYear and selectedMonth variable

@Gokul_Murali

I’m not sure why you’re unable to access it, but I’ll provide the detailed steps I used in my code below. Please follow these steps in your XAML:

Assign str monthname = “September”
Assign int MonthNumber = CInt(DateTime.ParseExact(monthName, “MMMM”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM”))

Assign String
FirstDay = New DateTime(Now.Year,MonthNumber,1).Tostring(“MM/dd/yyyy”)

Assign int DayinMonth = datetime.DaysInMonth(now.Year,MonthNumber)

Assign String LastDay = New Date(now.Year, MonthNumber, daysInMonth).Tostring(“MM/dd/yyyy”)

Output FirstDay and LastDay

Hi,

How about the following? This assumes it uses current year

Main.xaml (6.8 KB)

Regards,

@ Thank You guys

@Yoichi
@pradeep931
@Anil_G
@Gowtham_K115

1 Like

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