How to write a File Name with Date

Hi Team,
I have to write a file name along with week number in a month, could you please help with this doubt .

Thanks,
Manoj

@manojmanu.rpa ,
Can you share a sample filename Assuming Today’s Date?

Regards,

Hi @manojmanu.rpa

If you want to write the today’ date then use the expression and store it a variable.

  • Assign → Date = System.DateTime.Now.toString(dd-MM-yyyy)
    Pass this variable in the file name.

Hope it helps!!

Hi

FileName =YourVariableName + “_” +DateTime.Now.ToString(“yyyy-MM-dd”)

I hope this will help you,

Thank you

@manojmanu.rpa
Try this one to write week number in file.

"yourFilename"+DateTime.Now.ToString("MM") + "-" + (DateTime.Now.Day / 7 + 1).ToString()+"yourfileExtension"
1 Like

Hi @manojmanu.rpa

Please try this
“Filename_” + DateTime.Now.ToString(“MM”) + “Week” + ((DateTime.Now.Day - 1) / 7 + 1).ToString()

Thank you

Hi @manojmanu.rpa

Try this:

Datetime--->In_Date = Convert.ToDateTime("07/17/2023")
Datetime---->BaseDate = new DateTime(In_Date.Year, In_Date.Month, 1)
Int64---->out_week = DateAndTime.DateDiff(DateInterval.WeekOfYear ,Basedate, In_Date, FirstDayOfWeek.Monday,FirstWeekOfYear.Jan1)

Output: FileName + (out_week+1).ToString

Regards,

Hi @manojmanu.rpa

Here is the File with your Expected Output.

Assign activity: firstDayOfMonth = New DateTime(currentDate.Year, currentDate.Month, 1)
Assign activity: firstWeekNumber = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(firstDayOfMonth, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)
Assign activity: currentWeekNumber = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(currentDate, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)
Assign activity: weekNumberInMonth = currentWeekNumber - firstWeekNumber + 1

BlankProcess3.zip (389.9 KB)

Hope it helps!!

@manojmanu.rpa

Try this:

File_Name_Variable + System.DateTime.Now.toString(dd-MM-yyyy) + “.FIle_Extension”

This will work. Thanks

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