Different Date Format when Insert to Cell

Hello Guys,

My date is change form 3/8/2024 to 8/3/2024. I have find the date by using lastSaturday.ToString(“dd/MM/yyyy”) but when i try to insert this result to my excel by using write cell activity , it change to wrong format.

How do i fix this?

Hi @zaffan.isa

The format is automatically change to system date format when you are writing date to the excel by using the Write cell activity. After using write cell activity use the Format cells activity to change the format of the cell to the required date format.

→ Give the range in the Source field.
→ Click on Set format option in Format cells activity.
→ Then select the custom option in the Category and give the dd/MM/yyyy in the blank field.

Check the below image for better understanding,
image

Hope it helps!!

@zaffan.isa
Variables:

  • lastSaturday (DateTime) = (calculate last Saturday date)
  • formattedDate (String) = lastSaturday.ToString(“dd/MM/yyyy”)
  • formattedDateWithApostrophe (String) = “'” + formattedDate

Activities:

  1. Assign: formattedDate = lastSaturday.ToString(“dd/MM/yyyy”)
  2. Assign: formattedDateWithApostrophe = “'” + formattedDate
  3. Write Cell: Input (formattedDateWithApostrophe), Sheet (e.g., “Sheet1”), Cell (e.g., “A1”)

Hie @zaffan.isa hope this is the method you are achieving for
here is your input
image
change the last date format you want to achieve


here is the output
image
use this method to achieve the desired date format you want to apply in your code.
cheers Happy Automation

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