Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Convert string to date

So, I am at wits end on this question. I have a date picker in a writer document/form. I can read the chosen date easily enough (01/03/18). I can then break it down into a comma separated format easily enough (2018,01,03). Now the funk happens. When I try DateSerial() function it says no way - invalid function call. As overview, DateSerial(2018,01,03) works properly but a sting created using Left, Mid, Right will not work?

today = ThisComponent.Drawpage.Forms.getByName("Form").getByName("dteDatePick").tex

NewString= "20" + right(today,2) + ","
NewString = NewString + left(today,2)+ ","
NewString = NewString + mid(today,4,2) 

Print trim(NewString) 'gives the correct response


MsgBox DateSerial(NewString) 'gives invalid procedure call
click to hide/show revision 2
None

Convert string to date

So, I am at wits end on this question. I have a date picker in a writer document/form. I can read the chosen date easily enough (01/03/18). I can then break it down into a comma separated format easily enough (2018,01,03). Now the funk happens. When I try DateSerial() function it says no way - invalid function call. As overview, DateSerial(2018,01,03) works properly but a sting string created using Left, Mid, Right will not work?

today = ThisComponent.Drawpage.Forms.getByName("Form").getByName("dteDatePick").tex

NewString= "20" + right(today,2) + ","
NewString = NewString + left(today,2)+ ","
NewString = NewString + mid(today,4,2) 

Print trim(NewString) 'gives the correct response


MsgBox DateSerial(NewString) 'gives invalid procedure call