1. Andrew Davis
  2. PowerBuilder
  3. Monday, 22 May 2023 15:49 PM UTC

Hi 

Does anyone know how i can get the week of the year from a date, there does not seem to be a simple function for this.

as always any help greatly appreciated

regards

Andrew

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 22 May 2023 18:39 PM UTC
  2. PowerBuilder
  3. # 1

Hi Andrew;

  Considering the PB product's maturity, you would think that it would have a NumberOfWeeks() method but it does not. I would suggest though that you create a support ticket for this as an enhancement request.

In the meantime, I've always just used the DBMS's "week" related SQL support. For example:

SA: https://help.sap.com/docs/SAP_SQL_Anywhere/93079d4ba8e44920ae63ffb4def91f5b/81ffeccd6ce21014aa8fd702987f065e.html

SS: https://learn.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql?redirectedfrom=MSDN&view=sql-server-ver16

Check your DBMS documentation for your DB's specific support. HTH

Regards ... Chris 

Comment
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Monday, 22 May 2023 17:55 PM UTC
  2. PowerBuilder
  3. # 2

Hi Andrew,

In addition to John's PFC suggestion - and not sure what database you might be using - most databases have built-in functions providing this capability (EG DatePart() for SQL Server and PostgreSQL).

HTH...regards,

Mark

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 22 May 2023 17:52 PM UTC
  2. PowerBuilder
  3. # 3

Hi, Andrew -

If you have access to the PowerBuilder Foundation Class (PFC) libraries, the non-visual object pfc_n_cst_datetime in the pfcapsrv.pbl contains a method named of_WeekNumber that does what you want.

The code depends on a small number of other object functions within the same NVO.

The PFC libraries can be obtained from here:

    https://github.com/OpenSourcePFCLibraries

Best regards, John

Comment
  1. Francisco Martinez @Appeon
  2. Monday, 22 May 2023 17:56 PM UTC
If one's not familiar with C# I would go with this approach
  1. Helpful
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Monday, 22 May 2023 16:05 PM UTC
  2. PowerBuilder
  3. # 4

Hi Andrew,

If you're not afraid of trying something new, C# makes this very easy. You would just have to create a small C# library and use it on PowerBuilder.

Regards,
Francisco

Comment
  1. Andrew Davis
  2. Monday, 22 May 2023 16:40 PM UTC
Happy to try - i am using pb2019 at the moment have not moved the app that i need this on.



Are you able to explain how to do it ?
  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.