Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Solved] Is there a way to find out the format of user entered date?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Solved] Is there a way to find out the format of user entered date?
 Login/Join
 
Gold member
posted
Hello All,

I have a question regarding finding out the format of the user entered date.
The user has to provide the Begin Date and the End Date for the report. The users dont want to be restricted to enter the dates in a particular format.
Is there a way using which we can find out the format of the dates the user enters. As these dates are being used as filters, finding out the format is critical.

Thanks for your time.

This message has been edited. Last edited by: Kathleen Butler,


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
 
Posts: 82 | Registered: February 23, 2011Report This Post
Master
posted Hide Post
i don't know of any functionality that enables this short of EDITing out portions of the date and testing for a range of acceptable values (i.e. month token is between 1-12, Day token is not > 31). This has obvious drawbacks for dates where the day is <= 12.

The obvious solution is to use a calendar control and an HTML launch page to enforce the value selected. The calendar control brings its own bag of hurt with it, though.

- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Expert
posted Hide Post
Yes there is. You can do an EDIT on the incoming value and check for "pieces" of it for normal expectations.
quote:
The obvious solution is to use a calendar control and an HTML launch page to enforce the value selected.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Gold member
posted Hide Post
Hello ABT,

I know of the EDIT function, but as I dont know the exact format being entered, I would have to come up with all the possible combinations and keep on checking with them till the exact one is met.
As you said, the calendar control might be the only option.


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
 
Posts: 82 | Registered: February 23, 2011Report This Post
Virtuoso
posted Hide Post
Hello sumant,

What can you expect?
With slashes? Another delimiter? None?
4-digit year? 2-digit year?
European? American?
All?

I would check for one format and refuse the others!


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Expert
posted Hide Post
I've done it. All you need to do is to account for ALL The Possibilities that the user can enter. Consider the following code:
-SET &DateIn = &DATEMDYY ;
-SET &DateIn = &MDYY ;
-TYPE *** Incoming date: &DateIn, check to see if it has slashes...
-SET &Slash = IF &DateIn CONTAINS '/' THEN 'Slashes' ELSE 'NoSlashes' ;
-TYPE *** -GOTO &Slash
-GOTO &Slash.EVAL
-Slashes
-TYPE Do something about the date with slashes
-GOTO TheEnd
-NoSlashes
-TYPE Do something about the date without slashes
-GOTO TheEnd
-TheEnd
-TYPE *** Ta Da
-EXIT
... You can use the EDIT and associated DM commands to limit it to accept only those dates which YOU want to accept and consider the rest as an erroneous input and act (branch) accordingly...
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
quote:
I would check for one format and refuse the others!
... or a limited set of acceptable formats...
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Gold member
posted Hide Post
Hello Daniel,

Currently there are no set rules for the date formats to be entered. I will have a talk with my users and ask them to give me their most commonly used formats for dates. Based on them, I will use the EDIT function and extract the dates.


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
 
Posts: 82 | Registered: February 23, 2011Report This Post
Gold member
posted Hide Post
Hello Doug,

Thanks a lot for the sample code. I plan to ask my users for a limited set of acceptable formats and based on them extract the dates and use them in the filters.


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
 
Posts: 82 | Registered: February 23, 2011Report This Post
Expert
posted Hide Post
You're welcome.

About this:
quote:
Currently there are no set rules for the date formats to be entered.
... Someone needs to set some standards and we, as developers, need to accound for ANYTHING that we let in to our applications... Music
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Platinum Member
posted Hide Post
After many clients and and struggling with this for a few years, I try to talk each client into using the calendar control, with the edit box disabled. It is THE ONLY way to make absolutely sure the user does not type in an erroneous date.

This is the code I use for two calendar controls, defaulting to a 1 week date range, and producing a YYMD formated value to send to the report:

 
	var DateTo = new Date();
	var	DateToYear = DateTo.getYear();

	var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	// check for leap year
	if (((DateToYear % 4 == 0) && (DateToYear % 100 != 0)) || (DateToYear % 400 == 0)) monarr[1] = "29";

	var DateToDay = DateTo.getDate() - 1;

	if (DateToDay >= 1){
		DateToMonth = DateTo.getMonth() + 1;
		}
	else {
		LastMonth = DateTo.getMonth() - 1;
		DateToDay = DateToDay + monarr[LastMonth];
		DateToMonth = DateToMonth - 1;
		DateToYear = DateTo.getYear;
		if (DateToMonth == 0){
			DateToMonth = 12;
			DateToYear = DateToYear - 1;
			}		
		}
	if (DateToMonth < 10){
		DateToMonth = "0" + DateToMonth;
	}
	if (DateToDay < 10){
		DateToDay = "0" + DateToDay;
	}




//  starting date calculations below here

	var DateFromDay = DateTo.getDate() - 8;
	if (DateFromDay >= 1){
		DateFromMonth = DateTo.getMonth() + 1;
		DateFromYear = DateToYear;
		}
	else {
		LastMonth = DateTo.getMonth() - 1;
		DateFromDay = DateFromDay + monarr[LastMonth];
		DateFromMonth = DateToMonth - 1;
		DateFromYear = DateToYear;
		if (DateFromMonth == 0){
			DateFromMonth = 12;
			DateFromYear = DateToYear - 1;
			}		
		}
	if (DateFromMonth < 10){
		DateFromMonth = "0" + DateFromMonth;
	}
	if (DateFromDay < 10){
		DateFromDay = "0" + DateFromDay;
	}

//alert (DateFromYear);
	StartDate = DateFromYear + "/" + DateFromMonth + "/" + DateFromDay;
	EndDate = DateToYear + "/" + DateToMonth + "/" + DateToDay;


    a=document.getElementById("calendar1");
	a.value =StartDate;
	a.disabled=true;

    b=document.getElementById("calendar2");
	b.value =EndDate;
	b.disabled=true;

    c=document.getElementById("calendar3");
	c.value =StartDate;
	c.disabled=true;

    d=document.getElementById("calendar4");
	d.value =EndDate;
	d.disabled=true;

 


I mean really, even if the end user follows the 'rules' and uses leading zeros and slashes, what date do they really mean by '03/05/07'. Is that:


  • March 5, 2007
  • March 7, 2005
  • May 3, 2005
  • May 7, 2003
  • July 3, 2005
  • July 5, 2003


So just testing for format is only half the job.


Robert F. Bowley Jr.
Owner
TaRa Solutions, LLC

In WebFOCUS since 2001
 
Posts: 132 | Location: Gadsden, Al | Registered: July 22, 2005Report This Post
Gold member
posted Hide Post
Hello Robert,

Thanks a lot for the detailed reply and posting your code.
Will try it out.
I still will talk to my users for a list of acceptable formats to avaoid any furhter confusion.


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
 
Posts: 82 | Registered: February 23, 2011Report This Post
Virtuoso
posted Hide Post
Oh Calandar controls is the only way to go. Think about any Web sites you go to that involves dates...they always have a calendar there. Can you imagine an airline trying to accommodate every way a person would put in a date?
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
Expert
posted Hide Post
if you have a text box, then in the html, set the maximum length to, say, 8
and populate the default value in the text box
value=yyyymmdd
and that exact character string, yyyymmdd, will appear in the box when the user opens the launch page. the user ought to be able to figure it out.
or..
use 3 text boxes: year, month, day
they can't possibly get that wrong.
(oh ok, they can!)

btw... can one of you 77'ers tell me if the calendar controls have been improved? in 76, the calendar only popped up within the calling frame, and that never works for me, so i either use external .js for my calendar (tiger comes to mind), or i use dropdown boxes.
but if 77 has fixed that so that the calendar will pop up wherever you tell it to, i'ld love to know....

This message has been edited. Last edited by: susannah,




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Master
posted Hide Post
quote:
Originally posted by susannah:
if you have a text box, then in the html, set the maximum length to, say, 8
and populate the default value in the text box
value=yyyymmdd
and that exact character string, yyyymmdd, will appear in the box when the user opens the launch page. the user ought to be able to figure it out.
or..
use 3 text boxes: year, month, day
they can't possibly get that wrong.
(oh ok, they can!)


+1 - Unless you are a consultant who has to do the bidding of the person paying your fee or maintain an externally focused site that you don't wish to turn people (and their money) away, I'd suggest showing the user's the format expected and let them decipher the needs.

I can yell at my TV all day long for not changing channels when I press the volume buttons and as developers, we should not be expected to 'intercept' their intentions. Only judge their actions.

- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Expert
posted Hide Post
As it has been repeatedly stated, the calendar control is the only way to go, to be sure.

Otherwise, an entry field limited to 8/10 chars with a stated format that is accepted.

e.g.
Format DD/MM/YYYY

If they enter the date 01/12/2012, and expect it to be the 12th of the Jan, then its there own fault for not reading the screen.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6349 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Gold member
posted Hide Post
Thanks everyone for your replies.
I spoke to my users and we have agreed to use calendar controls.


WebFOCUS 7.7.02Windows
Output Formats: Excel, HTML, PDF
 
Posts: 82 | Registered: February 23, 2011Report This Post
Master
posted Hide Post
quote:
Originally posted by sumant:
... and we have agreed to use calendar controls.


And so the fun begins... Wink
- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
 
Posts: 561 | Registered: February 03, 2010Report This Post
Platinum Member
posted Hide Post
I've also used the technique of filling a dynamic parameter drop down with dates selected from the data source. Then make them pick from those.


WebFOCUS 7.7.05 (Someday 8)
Windows 7, All Outputs
In Focus since 1983.
 
Posts: 103 | Registered: April 27, 2011Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Solved] Is there a way to find out the format of user entered date?

Copyright © 1996-2020 Information Builders