Subject | Re: [firebird-support] How do I convert CURRENT_TIME and CURRENT_DATE to a string? (SOLVED) |
---|---|
Author | SoftTech |
Post date | 2008-11-16T11:49:16Z |
Greetings All,
I have figured out the best way to do the time.
/* Convert the time to a string in the format HHMMSS */
sTime ='';
if (EXTRACT(HOUR FROM CURRENT_TIME) < 10) then
sTime = sTime || '0';
sTime = sTime || EXTRACT(HOUR FROM CURRENT_TIME);
if (EXTRACT(MINUTE FROM CURRENT_TIME) < 10) then
sTime = sTime || '0';
sTime = sTime || EXTRACT(MINUTE FROM CURRENT_TIME);
if (EXTRACT(SECOND FROM CURRENT_TIME) < 10) then
sTime = sTime || '0';
sTime = sTime || EXTRACT(SECOND FROM CURRENT_TIME);
FILE_TIME = SUBSTRING(sTime FROM 1 FOR 6);
and here is how I did the data in case anyone is interested, thanks to Svein Erling Tysvaer
/* Convert the date to a string in the format year month date 20081116 */
sDate = '';
sDate = EXTRACT(YEAR FROM CURRENT_DATE);
if (EXTRACT(MONTH FROM CURRENT_DATE) < 10) then
sDate = sDate || '0';
sDate = sDate || EXTRACT(MONTH FROM CURRENT_DATE);
if (EXTRACT(DAY FROM CURRENT_DATE) < 10) then
sDate = sDate || '0';
sDate = sDate || EXTRACT(DAY FROM CURRENT_DATE);
FILE_DATE = sDate;
Thanks to all for you help,
Mike
[Non-text portions of this message have been removed]
I have figured out the best way to do the time.
/* Convert the time to a string in the format HHMMSS */
sTime ='';
if (EXTRACT(HOUR FROM CURRENT_TIME) < 10) then
sTime = sTime || '0';
sTime = sTime || EXTRACT(HOUR FROM CURRENT_TIME);
if (EXTRACT(MINUTE FROM CURRENT_TIME) < 10) then
sTime = sTime || '0';
sTime = sTime || EXTRACT(MINUTE FROM CURRENT_TIME);
if (EXTRACT(SECOND FROM CURRENT_TIME) < 10) then
sTime = sTime || '0';
sTime = sTime || EXTRACT(SECOND FROM CURRENT_TIME);
FILE_TIME = SUBSTRING(sTime FROM 1 FOR 6);
and here is how I did the data in case anyone is interested, thanks to Svein Erling Tysvaer
/* Convert the date to a string in the format year month date 20081116 */
sDate = '';
sDate = EXTRACT(YEAR FROM CURRENT_DATE);
if (EXTRACT(MONTH FROM CURRENT_DATE) < 10) then
sDate = sDate || '0';
sDate = sDate || EXTRACT(MONTH FROM CURRENT_DATE);
if (EXTRACT(DAY FROM CURRENT_DATE) < 10) then
sDate = sDate || '0';
sDate = sDate || EXTRACT(DAY FROM CURRENT_DATE);
FILE_DATE = sDate;
Thanks to all for you help,
Mike
[Non-text portions of this message have been removed]