Subject RE: [firebird-support] Extract "name of the day" from date
Author Svein Erling Tysvær
Alternatively (if you don't like UDFs), you can use something like (using 31 December 1899 since that apparently was a Sunday, use 1 January 1900 if you think the week starts on Monday, note that that date must be prior to any date you want to know the day of):

Select case current_date - cast('31.12.1899' as Date) -
((current_date - cast('31.12.1899' as Date))/7)*7
when 0 then 'Sunday'
when 1 then 'Monday'
when 2 then 'Tuesday'
when 3 then 'Wednesday'
when 4 then 'Thursday'
when 5 then 'Friday'
when 6 then 'Saturday'
end as NameOfToday
from rdb$database

This works with Firebird 1.5 and hopefully all newer versions,
Set

-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of Olaf Kluge
Sent: 5. februar 2009 15:02
To: firebird-support@yahoogroups.com
Subject: AW: [firebird-support] Extract "name of the day" from date

Hello,

you can use a separate dll (freeadhocudf.dll) and create a udf in firebird.
Take it to your udf-folder. After you have installed it you can use the
F_DATETOSTR - function.

F_DATETOSTR Input/Output-kompatibel zu rFunc (DATETOSTR)
Entrypoint datetostr
Input TIMESTAMP
CSTRING(254)
Datum-Zeitwert
Pattern, wie Datum-Zeit aussehen soll
Output CSTRING(254) formatiertes Datum entsprechend Parameter 2
Pattern für Parameter 2 (wie von c-Funktion strftime):
%% - Zeichen %
%c - Datum/Uhrzeit
%x - Datum
%d - Tag des Monats (01-31)
%j - Tag des Jahres (000-366)
%w - Tag der Woche (0-6), 0 = Sonntag
%U - (US-)Kalenderwoche (00-53), Sonntag erster Tag der Woche
%W- (US-)Kalenderwoche (00-53), Montag erster Tag der Woche
%a - Kurzform Wochentag (in englisch)
%A -Langform Wochentag (in englisch)
%m - Monat (01-12) (in englisch)
%b - Kurzname Monat (in englisch)
%B - Langname Monat (in englisch)
%y - Jahr 2-stellig (00-99)
%Y - Jahr 4-stellig
%X - Uhrzeit
%H - Stunden 24-h Format (00-23)
%I - Stunden 12-h Format (01-12)
%M - Minuten (00-59)
%p - AM or PM
%S - Sekunden (00-59)


http://udf.adhoc-data.de/

With best regards

Olaf Kluge
________________________________________
Von: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] Im Auftrag von Sasa Mihajlovic
Gesendet: Donnerstag, 5. Februar 2009 11:11
An: firebird-support@yahoogroups.com
Betreff: [firebird-support] Extract "name of the day" from date

Hi,

Does firebird can return name of day from DATE param?

Thank in advance