Convert DateTime to string and remove unwanted time?

Hey,

I have a variable A=11/20/2018 00:00:00, type of it is DateTime

How to get a string as 20.11.18? Thanks

1 Like

Hi.

Using vb.net you can place the format next to the .ToString
For example:

variable.ToString("dd.MM.yy")

…assuming the variable is of a DateTime type, which if it is not, then you would need to convert it first.

Regards.

1 Like

Use

Convert.ToDateTime(A).ToString(“dd.MM.yy”)

It Will Work Fine

3 Likes

Hi @ClaytonM @Himanshu.joshi

both commands are not working with me. I shared the workflow and made an annotation where the conversion is required. Can you please check it?
Main.xaml (8.6 KB)

1 Like

It worked for me. See screenshot highlighted in yellow…

Thanks.

1 Like

Main (6).xaml (7.2 KB)

Here is The Workflow Which Works fine.

1 Like

That is really nice but I dont only want to display it using message box. I wanna save the Date 20.11.18 as string in variable. How? Because I keep becoming error while assigning it to a new string variable. Thanks

1 Like

The Varialbe i which you assign will be string type

String var=Convert.ToDateTime(CD).ToString(“dd.MM.yy”)

2 Likes

Hi
This is answer for your question

A.ToString(“dd.MM.yy”)

try various format, follow below link

Thanks

1 Like

I used a.date.toshortdatestring() to extract just the date into string.

1 Like

It Worked for me fine , Thanks for the solution

1 Like

Hi @Kesavaraj_K
If this works for you please mark this as a solution. So this will be helpful for other community members as well

1 Like