Get only date from date and time

I have date in a string variable in format

str1 - 27/10/2020 05:52:13

I want only date from this
So output will be like

Output - 27/10/2020

Please help

Hi Ravi,

You can use assign activity to get only date from date time format.

Option 1 - Date Time is already in string variable

string sDateTime = 27/10/2020 05:52:13
string sDate= Split(sDateTime)(0)

Option 2 - Date and Time is available in DateAndTime variable of type DateTime.

string sDate = DateAndTime.ToString("dd/MM/yyyy")

Hope this helps.

Hi @ravig1206,

Should the value be a Date Type or a String Type?

Date Type: This Post May Help

String Type: DateTime.ToString(“dd/MM/yyyy”)

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