Question

In a number of datawindows in my application, users have access to a free-form text box where they can enter any filter string they like. Frequently, they will successfully use a search term like: date(last_updated_date) = 2010-10-22

I'm trying to update some documentation and have been asked to address this syntax in particular. So my question is this: how does PowerBuilder know that "2010-10-22" is a date and what are the rules for including date literals like this one without specific conversion? Is it based upon the fact that the left-hand value is clearly a date datatype or is it based upon the particular date format used in "2010-10-22" or both? Just to be clear: this syntax woks properly.

Was it helpful?

Solution

It is definitely the format for literal dates (without quotes), and there is no need to compare with the left side of the comparison to handle it as a date.

In the "Standard dataypes" section, the documentation states for the type "Date":

The date, including the full year (1000 to 3000), the number of the month (01 to 12), and the day (01 to 31). Using literals To assign a literal value, separate the year, month, and day with hyphens. For example:

2001-12-25 // December 25, 2001

2003-02-06 // February 6, 2003

OTHER TIPS

All what Seki said about the literals it’s true. If you want/have to use strings however, the format „yyyy-mm-dd” is the one that will always work when comparing with/assigning to a date type variable. It’s considered the standard for date format.

If a different string format is used as a date, for example „25-12-2012”, PB uses Windows regional settings to convert it. If conversion fails you’ll get 1900-01-01.

You can also check PB help „Date PowerScript function/Convert a string to a date”.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top