Assigning string to store as datetime variable

Hi All,

I’m required to read last month/year from an excel, assigning q1 - q4 as datetime variable & use it to replaces text on a word file with if function.
How do I assign a string to store datetime variable like q1 - q4?
Also, The dates on the excel goes like “jan-18 feb-18”, how do I read the month & year individually?

Thanks in advance!

You can read the complete string at once then use inputstring.substring(0,3) - this will return you month and inputstring.substring(4,2) this will return you year

I keep getting Excel application scope: Exception from HRESULT: 0x800A03EC" error when I wanna print it out using writeline?

See this post that relates to the error resolution

1 Like

What about assigning date, how do I get part of a date & store it as a variable?

If you want to get month and year from your excel you can achieve by the way I mentioned previously or you can convert that into convert.datatime(your input string, format) and then you can just get datevariable.month and datevariable.year.

1 Like