Yesterday's date

Hello! I need yesterday’s date in dd.mm.yyyy format, please help :slight_smile:
Thank You! :slight_smile: I found something like this: DateTime.Now.AddDays(-1) but I don’t know where to add the format

Hi @sullivanne

yesterdayDate = DateTime.Now.AddDays(-1).ToString("dd.MM.yyyy")

Regards,

1 Like

@sullivanne,

Use this in wherever you need this format.

DateTime.Now.AddDays(-1).ToString("dd.MM.yyyy")

For example you can print this using MessageBox. Put this code in text to print.

Sample Code:
Yesterdays Date.zip (142.8 KB)

Thanks,
Ashok :slight_smile:

1 Like

Hie @sullivanne
A message box in a software application displays the date "20.08.2024" using an expression that subtracts one day from the current date. (Captioned by AI)
try this method

now.AddDays(-1).ToString(“dd.MM.yyyy”)

1 Like

@sullivanne,

Added sample code.

Thanks,
Ashok :slight_smile:

1 Like

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