Schultz’s PowerBuilder Notes

PFC DateTime Service (n_cst_datetime)


The Date/Time service provides methods to perform calculations with dates.
It includes the following features:

  • Convert seconds to either days or hours
  • Convert between Julian and Gregorian dates
  • Identify the Julian day number for a given date
  • Identify the week number for a given date
  • Identify the day of the week for a given date
  • Determine the first or last date of the month for a specified date
  • Determine if a date falls within a leap year
  • Determine if a date is a weekday or on the weekend
  • Validate a value to see if it is a valid date or DateTime
  • Compute the number of milliseconds between two times
  • Compute the number of whole weeks, months, or years between two dates
  • Compute the number of seconds between two DateTime values
  • Obtain relative dates before/after specified seconds, months or years
  • Stop processing until a specified date/time is reached

How do I time how long an activity takes?

Use of_SecondsAfter() or of_MilliSecsAfter()

datetime ldtm_begin, ldtm_end
n_cst_datetime lnv_datetime

ldtm_begin = Datetime(Today(), Now())

// Stuff you want to time is here

ldtm_end = Datetime(Today(), Now())
MessageBox("Time check", String(lnv_datetime.of_SecondsAfter(ldtm_begin, ldtm_end)))

How do I validate if a datetime has been populated?

True if the value is not null or equal to the datetime default

lnv_datetime.of_IsValid(ldtm_check)

How do I find the day of the week?

Use the of_DayOfWeek function :

datetime.of_DayOfWeek ( sourcedate )

Argument: date (sourcedate) Date variable that contains the day to be determined

Returns : Integer. (values, as follows)

1 Sunday

2 Monday

3 Tuesday

4 Wednesday

5 Thursday

6 Friday

7 Saturday

About these ads

July 16, 2008 - Posted by | 3. PFC, Utility Services | , , , , , , , , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: