Emmit,
As an alternative why not just SET VAR vmm = (FORMAT(.#DATE,’MM’))
no need to convert to an integer first
Jim Bentley
American Celiac Society
[email protected]
tel: 1-504-737-3293




________________________________
From: Emmitt Dove <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Tuesday, August 18, 2009 11:27:31 AM
Subject: [RBASE-L] - Re: SSub Declare date var

  
That doesn’t explain:
 
SET VAR vmm = (FORMAT(IMON(.#DATE),’00’))
 
Emmitt Dove
Manager, Converting Applications Development
Evergreen Packaging, Inc.
[email protected]
(203) 214-5683 m
(203) 643-8022 o
(203) 643-8086 f
[email protected]
 
From:[email protected]
[mailto:[email protected]] On Behalf Of Dennis McGrath
Sent: Tuesday, August 18, 2009 12:05 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: SSub Declare date var
 
When you are formatting numbers, a leading space is the default placeholder
for negative sign.
SET VAR vctext TEXT = (FORMAT(.vcurr,’[-]990.00’)) will put the
sign at the end, eliminating the leading space.
 
Dennis McGrath
 

________________________________
 
From:[email protected]
[mailto:[email protected]] On Behalf Of Emmitt Dove
Sent: Tuesday, August 18, 2009 10:58 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: SSub Declare date var
 
Harumph.  In this case, FORMAT does NOT leave a leading
space.
 
But:
 
SET VAR vcurr CURRENCY = $123.04
SET VAR vctext TEXT = (FORMAT(.vcurr,’990.00’))
 
… will leave a leading space on the variable vctext.
 
What determines when the leading space appears?
 
Emmitt Dove
Manager, Converting Applications Development
Evergreen Packaging, Inc.
[email protected]
(203) 214-5683 m
(203) 643-8022 o
(203) 643-8086 f
[email protected]
 
From:[email protected]
[mailto:[email protected]] On Behalf Of Emmitt Dove
Sent: Tuesday, August 18, 2009 11:48 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: SSub Declare date var
 
Why?  Because, Jim, sometimes one’s mind just isn’t focused
on the straightforward solution!
 
I’d never thought of just using FORMAT that way …
 
One note though:  FORMAT will leave a leading blank in your
result, so you either need to do an SGET or use SSTRIP to strip it.
 
Emmitt Dove
Manager, Converting Applications Development
Evergreen Packaging, Inc.
[email protected]
(203) 214-5683 m
(203) 643-8022 o
(203) 643-8086 f
[email protected]
 
From:[email protected]
[mailto:[email protected]] On Behalf Of James Bentley
Sent: Tuesday, August 18, 2009 10:01 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: SSub Declare date var
 
Oh why? Oh why? do you go through all that manipulation when
there is the FORMAT function.
Check out the latest documentation. RBase has recently re-documented additional
syntax for using the FORMAT function to format DATE, TIME, and TIMESTAMP data
types. The only addition they made was to add "NN" for use in place
of "MM" of the time part of TIMESTAMP data types.
 All you have to do is get you data into one of the above data types then
Set
var V2 text = ((FORMAT(.vdatevar,'YYYYMMDD')) + .vLFNFileNameS1)  

Several cautions I observe in forming file names.
1. NEVER, I repeat NEVER use imbeded spaces or characters other than 'a-z',0-9
in a file name as someday it will come back to haunt you. You could possibly
use special characters as "#$"
2.  I always start file names with an alpha character.
3. If you use date and time or date only as part of file name use YYYYMMDD as
the format instead of MMDDYYYY. It is a natural way of easily ordering and
grouping the filenames.
 
Jim Bentley
American Celiac Society
[email protected]
tel: 1-504-737-3293
 
 

________________________________
 
From:Emmitt Dove
<[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Monday, August 17, 2009 12:35:28 PM
Subject: [RBASE-L] - Re: SSub Declare date var
Paul,
 
The reason that
 
Set Var v2 date = (ssub(.vLFNFileDT1,-1))  
 
fails is that you cannot assign the results of an expression
which evaluates to a TEXT datatype to a DATE datatype.  The two-step
approach works because R:BASE lets you create a DATE variable by assigning a
text value without the use of a function call.  Honestly, that is
non-standard.  Use it all the time; love it; wouldn’t ever want to see it
changed.  But non-standard.  It is really an implied function call:
 
SET VAR v2 DATE = (ConvertToDate(SSUB(.vLFNFileDT1,-1))) 
 
Now, you *could* write your own function (stored
procedure) ConvertToDate that does nothing but create a date variable from a
text input … or you can use a long string of nested functions to get to your
result in one step.
 
R>SET VAR vresult TEXT = 
(CTXT(IYR4(.#DATE))+SGET(FORMAT(IMON(.#DATE),'00'),2,2)+SGET(FORMAT(IDAY(.#DATE),'00'),2,2))
 
R>SHO VAR
Variable          
=
Value                                  
Type
------------------  
------------------------------         
--------
#DATE             
= 08/17/2009                              
DATE    
#TIME             
=
13:34:19                                
TIME    
#PI               
=
3.14159265358979                        
DOUBLE  
SQLCODE           
=
0                                       
INTEGER 
SQLSTATE          
=
00000                                   
TEXT    
#NOW              
= 08/17/2009
13:34:19                     
DATETIME
vresult           
=
20090817              
                  TEXT   
 
You can take the above and, in the same step, tack on whatever
else you want for filename … or expand it to include the time in the string, or
both.
 
Emmitt Dove
Manager, Converting Applications Development
Evergreen Packaging, Inc.
[email protected]
(203) 214-5683 m
(203) 643-8022 o
(203) 643-8086 f
[email protected]
 
From:[email protected]
[mailto:[email protected]] On Behalf Of Paul InterlockInfo
Sent: Monday, August 17, 2009 12:41 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: SSub Declare date var
 
Set var vLFNFileDT1 text = ‘8/17/2009 4:23 AM’
 
Now that we get this var from a RBL so no changing it!  But
I would like var v_something Text = ‘20090817’  Lead year for file use,
zero filed months and days etc..  Time could be nice also but not required
in this case.
 
 
So I would assume Set Var v2 date =
(ssub(.vLFNFileDT1,-1))   fails!   
But: 
      Set Var v3 = (ssub(.vLFNFileDT1,-1))   
               
Set Var v4 date = .v3 provides the date value  As expected.
 
That way you could set Date =
‘YYYYMMDD’ and add that part in the string and put it together in front of a
file name.
 
Seems simple, but I am missing the first step that fails. I
could include this long declare var this/that (v1,v2,v3,…) but it would be nice
in 1-2 var
 
 
 
Set Date YYYYMMDD
Set var V2 text = ((ssub(.v1,-1))  &
.vLFNFileNameS1)  
Set Date MM/DD/YYYY
 
However I know that is impossible.  Thought about using
#NOW and loading that into a var?  Not possible from what I can see.
Example:
Set var v1 #NOW = . vLFNFileDT1 and then switch it to a text var
with YYYYMMDD HHMM.  Also again adding steps.
 
 
Any ideas why “Set Var v2 date =
(ssub(.vLFNFileDT1,-1))”   fails?    Am I missing
something in quotes or ?  Not possible and just take the addn’l steps?
 
 
 
 
 
Sincerely,
Paul Dewey 


      

Reply via email to