How to get current system date in mm/dd/yyyy format?

uiautomation
studio

#1

Hi Guys,

How to get current system date in mm/dd/yyyy format ?

Thanks,
Vishal Kumar


#2

Hi @vishal.kumar

Approaches can be many, here is the simplest one.

Dateinformatsample.xaml (6.3 KB)


#3

Hi Viswanath,

This approach sounds good. How can i add 30 days to the system date obtained?

eg: system date: 11/21/2017 and I want the date to be set as 30 days from today i.e 12/21/2017

Thanks,
Vishal kumar


#4

Hai @vishal.kumar

Please find the updated .xaml file.

Let me know if u have any queries on the same.

Dateinformatsample.xaml (6.3 KB)


#5

@vishal.kumar try this Convert.toDateTime(now.tostring(“MM/dd/yyyy”)).AddDays(30).ToString

Update: use this now.AddDays(30).tostring(“MM/dd/yyyy”) it will give you desired result “12/21/2017” instead of “12/21/2017 00:00:00”


#6

Hi @vishal.kumar ,

Lets try this as mentioned @AkshaySandhu .


#7

Try this:
System.DateTime.Now.ToString(“MM/dd/yyyy”)