Razzak,
I did a slight modification to you example:
SET VAR vFileName =
((CVAL('DATABASE'))+'_'+(FORMAT(.#NOW,'YYYYMMDD_HHNN'))+'.BKP')
Which in my case returns:
vFileName = BETAXIAD_20090216_1301.BKP TEXT
Note the ability to use key items in different order. I like to put the year
first when creating file names that way a directory listing (ordered) presents
file name in descending or ascending order by month and day with year.
Another example:
set var vdatefmt text =(FORMAT(.#DATE,'DD-MMM-YYYY')) returns
vdatefmt = 16-Feb-2009 TEXT
or
set var vdatefmt text =(FORMAT(.#DATE,'MMM+ dd, YYYY cc')) returns
vdatefmt = February 16, 2009 AD TEXT
or
set var vdatefmt text =(FORMAT(.#DATE,'Www+: MMM+ dd, YYYY '))
vdatefmt = Monday: February 16, 2009 TEXT
For time:
set var vTime TEXT=(FORMAT(.#TIME,'HH:MM:SS.SSS')) returns
vTime = 13:23:31.000 TEXT
or
set var vTime TEXT=(FORMAT(.#TIME,'HH:MM:SS AP')) returns
vTime = 1:25:11 PM TEXT
or even (although I can't imagine why)
set var vTime TEXT=(FORMAT(.#TIME,'AP MM/HH:SS')) returns
vTime = PM 26/01:38 TEXT
Imagine the possibilities!
No mucking with the SET TIME and SET DATE commands and their consequent dangers
in a multi-user environment.
Jim Bentley
American Celiac Society
[email protected]
tel: 1-504-737-3293
--- On Mon, 2/16/09, A. Razzak Memon <[email protected]> wrote:
From: A. Razzak Memon <[email protected]>
Subject: [RBASE-L] - Enhanced FORMAT Function (was Re: Problem printing to PDF
file)
To: "RBASE-L Mailing List" <[email protected]>
Date: Monday, February 16, 2009, 12:46 PM
At 12:50 PM 2/16/2009, James Bentley wrote:
>Razzak,
>
>Thanks for calling attention to undocumented features of the
>FORMAT function. At one time way back when either in old
>documentation or in a discussion post the syntax to format
>DATE and TIME variables was mentioned. If you access the
>SET DATE and SET TIME commands you will find such key words
>as MMM, MMM+, MM, DD, YY, YYYY, HH, MM (for time ), SS, AP,
>etc. that can be used in the FORMAT function. Also, note
>that the recent implimentation of "NN" as a replacement for
>"MM" in time allows you to format DATETIME values.
The pleasure is all mine, James!
The ability to use FORMAT function to create file names and
more, without mucking with the connected database settings,
especially in a multi-user environment, is a cool function
of R:BASE!
Yes, the latest enhancement to support .#NOW System Variable
using FORMAT function enables a nice feature to create dynamic
file name(s) when defining automated database backup routines.
Since the introduction of this enhancement, I have been using
the following backup routine in my External Form File Timer.
The whole string to create a dynamic file name can be defined
in a "single" command.
-- Example
CLEAR VARIABLES vFileName
SET VAR vFileName TEXT = NULL
IF (CVAL('DATABASE')) <> 'RRBYW16' OR
(CVAL('DATABASE')) IS NULL THEN
CONNECT RRBYW16 IDENTIFIED BY NONE
ENDIF
CLS
SET VAR vFileName = +
((CVAL('DATABASE'))+'_'+(FORMAT(.#NOW,'MMDDYYYY_HHNN'))+'.BKP')
-- Notice the "NN" for minutes when using .#NOW (not a typo)
-- vFileName will return the text variable as:
-- RRBYW16_02142009_1350.BKP
-- Date and Time will vary on your end
OUTPUT .vFileName ENCRYPT password
UNLOAD ALL
OUTPUT SCREEN
RETURN
Once the file is created, you may use "RBZip.RBL" Plugin to
compress the file and then FTP the entire backup file to a
secure FTP server using "RSFTP.RBL" Plugin.
The whole process is totally automated without human interaction.
Very Best R:egards,
Razzak.