Extracting month,day, and year from the date

Hi everyone,

I have a date variable (currently set to generic value). It is pulling data from excel and typing into pdf form. In excel it reads mm/dd/yyyy format. But on the pdf form, it needs the month, day, and year in separate boxes. I tried datevariable.ToString(“mm”) for month but it only types “mm” onto the pdf. Any ideas? Do I need to change the variable type?


To get month from your Datetime variable you should call .ToString(“MM”) in capitals to call month numbers.

Day and year are both lower case. - “dd” and “yyyy”


Still didn’t work, it just typed “MM” into the pdf field

You will need to convert the value into a datetime variable then before extracting the information

DateTimeVariable = Datetime.Parse(datevariable)
You can then use DateTimeVariable.ToString(“MM”)


I was thinking, if you already have a string you can split it on basis of / and then use the values 0,1,2 respectively
IF you are going to have to covert etc. because you want a string value, not necessarily a date.

I used DateTime.Parse(datevariable).ToString(“MMMM”) and it worked. Thanks!


Yes, I have extracted in string datatype only.

1 Like

Thankyou, that works for me.