1. Avory Rose Pastoral
  2. PowerBuilder
  3. Friday, 10 September 2021 09:02 AM UTC

Hi Everyone,

 

I have a script where I upload my excel file and read it using pb script 

On my excel file this is how I display my date : WEDNESDAY, JANUARY 1, 2020

And this how I read it

s_logdte = trim(string(myoleobject.application.workbooks(1).worksheets(1).cells(3,5).value))
s_logdte = mid(s_logdte,11,40)
dt_date = datetime(date(s_logdte))

 

But i'm having trouble on how will I trim the date to only DATE without the DAYNAME

 

I have attached a screenshot for your reference.

 

 

 

 

 

 

Attachments (1)
Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 10 September 2021 13:36 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Avory;

  FWIW: I would use a POS() command ahead of the MID() command to locate the proper start of the month name.  HTH

Regards ... Chris

Comment
There are no comments made yet.
Avory Rose Pastoral Accepted Answer Pending Moderation
  1. Tuesday, 14 September 2021 02:47 AM UTC
  2. PowerBuilder
  3. # 1

Was able to make it work by using post(). Thank you so much!

Comment
There are no comments made yet.
Avory Rose Pastoral Accepted Answer Pending Moderation
  1. Tuesday, 14 September 2021 02:33 AM UTC
  2. PowerBuilder
  3. # 2

This is the output

Attachments (1)
Comment
There are no comments made yet.
Avory Rose Pastoral Accepted Answer Pending Moderation
  1. Tuesday, 14 September 2021 02:30 AM UTC
  2. PowerBuilder
  3. # 3

Tried this but the output is {}

Comment
There are no comments made yet.
Avory Rose Pastoral Accepted Answer Pending Moderation
  1. Tuesday, 14 September 2021 01:46 AM UTC
  2. PowerBuilder
  3. # 4

How will I able to do that if the length of the month name is changing? 

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 10 September 2021 10:35 AM UTC
  2. PowerBuilder
  3. # 5

Dateformats for string() function:

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 10 September 2021 10:23 AM UTC
  2. PowerBuilder
  3. # 6

Try:

// try to apply "[shortdate]", "mm/dd/yy" (or "dd/mm/yy") see the pb help on the string() function
s_logdte = string(trim(string(myoleobject.application.workbooks(1).worksheets(1).cells(3,5).value)), "[shortdate]")
Comment
  1. Miguel Leeuwe
  2. Friday, 10 September 2021 10:35 AM UTC
I'm not sure why your are converting the value to a string in the first place if the excel value is not a string?

If you don't want "01/01/2020", but "JANUARY 1, 2020", then use the format: "mmmm" for January or "mmm" for Jan ...

See the image of pb help in my next answer.

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.