Date Format like 31-Jan-2018


#1

How can i get/convert the date format as 31-Jan-2018?

I would like to input that date format into a field.

thank you.


#2

Hi. Assuming the date string is in a format already like MM/dd/yy or MMM dd, yyyy, for example, then you can use the vb CDate() or Convert.ToDate(), then .ToString(format)

For example,

CDate("5/25/2018").ToString("dd-MMM-yyyy")

If your date string is of a different country than I’m used to where it’s reversed like “dd/MM/yyyy”, then you will need to use ParseExact I think. Refer to the Search option to find examples of that method.

Regards.


#3

hi @criskitz

StringVar.ToString(“dd-MMM-yyyy”);

Thanks
Ashwin S


#4

Hello @criskitz,

Use the below statement,
String currentDate;
currentDate = Now.Date.ToString(“dd-MMM-yyyy”);

Have a look at result,
Date_Format

Thanks,
Pankaj


#5

Thank you all for the response! currentDate = Now.Date.ToString(“dd-MMM-yyyy”) is working. :slight_smile:


#6

Hi @criskitz,
You can try this one also.

currentDate = Date.Today.ToString(“dd-MMM-yyyy”)

Regards
Balamurugan