Deutsch English
Alphabetical index
Array functions
CGI functions
Data types
Date functions
  • datestr()
  • datetime_to_unix()
  • day()
  • dayofweek()
  • monat()
  • month()
  • now()
  • str_to_unixtime()
  • timestr()
  • unixtime_to_str()
  • unix_date()
  • unix_now()
  • unix_time()
  • week()
  • year()
    Debugging
    Fulltext functions
    Language elements
    Numerical functions
    Operators
    Other functions
    Ramtext functions
    Selecting
    Socket functions
    Statistical functions
    Stream functions
    String functions
    System functions
    Table functions
    Text functions
    Home    Overview    Search    Impressum    Contact    Members
    Topic complex Date functions
    Function dayofweek()
    Short Weekday of a date
    Syntax DAYOFWEEK(date : INTEGER) : STRING
    Parameter date : date in the format of the tdbengine (days since 0000-01-01)
    Return Weekday of a date (German)
    "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"
    See also:
    today()
    Description Example:

    "Today is "+DAYOFWEEK(TODAY)+", the "+DATESTR(TODAY) ->

    Today is Dienstag, the 13.06.2000

    You get the original value of the weekday with the formula:

    1+(date+5) MOD 7

    1 = monday
    2 = tuesday
    ...

    Consequently you can write an own function DayOfWeek:

    PROCEDURE DayOfWeek(date : INTEGER) : STRING
    VAR w_day : INTEGER
    w_day:=1+(date+5) MOD 7
    IF w_day=1 THEN RETURN "Monday"
    ELSIF w_day=2 THEN RETURN "Tuesday"
    ELSIF w_day=3 THEN RETURN "Wednesday"
    ...
    END
    ENDPROC

    or shorter

    RETURN choice(w_day,"mon","tue","wed","thu","fri","sat","sun")


    Example 1: DayOfWeek



    PROCEDURE DayOfWeek(date : INTEGER) : STRING
    VAR w_day : INTEGER w_day:=1+(date+4) MOD 7
    IF w_day=1 THEN RETURN "monday"
    ELSIF w_day=2 THEN RETURN "tuesday"
    ELSIF w_day=3 THEN RETURN "wednesday"
    ...
    // oder kürzer
    // RETURN choice(w_day,"mo","di","mi","do","fr","sa","so")
    END
    ENDPROC
    


    User comments:
    Write a comment:
    Name
    EMail
    Subject
    Text (Switch mode)

    Choose between
    the normal and the
    advanced editor.
    The advanced editor
    runs in IE 5+ and
    Mozilla 1.4+ only
    SPAM-Protection Please enter tdbengine in this field.

    tdbengine chat
    irc.tdbengine.org
    #tdbengine

       Copyright © 2003-2004 tdb Software Service GmbH
       Alle rechte vorbehalten. / All rights reserved
       Last changed: 21.10.2004
    {Fehler für :execmacro{execmacro="sessionspy"}