date algorithm

does anybody know a way to calculate the day of the week, if any gievn date is given?

eg:

enter date: 12/04/04

the program would then say: monday

thanks to all that help.

Comments

  • : does anybody know a way to calculate the day of the week, if any gievn date is given?
    :
    : eg:
    :
    : enter date: 12/04/04
    :
    : the program would then say: monday
    :
    : thanks to all that help.
    :
    :
    First EncodeDate() the entered values into a TDateTime variable. Then decode it the DecodeDate() procedure. It includes the DayOfTheWeek. See the help files for more info.
  • I can't find EncodeDate() & DecodeDate() in any Pascal unit,
    is it your custom procedure? where is the source??
  • : I can't find EncodeDate() & DecodeDate() in any Pascal unit,
    : is it your custom procedure? where is the source??
    :
    It isn't a custom procedure, otherwise I would have given the source in my previous post. It's part of the FreePascal DOS unit. In case of TP you need use the SetDate() and GetDate(). Here is a function, which returns the day of the week:
    [code]
    function DayOfWeek(Day, Month, Year: word): word;
    var
    d, m, y: word;
    begin
    GetDate(d, m, y, DayOfWeek); { Save the old system date }
    SetDate(Day, Month, Year); { Set the new date }
    GetDate(Day, Month, Year, DayOfWeek); { Get the actual day of the week }
    SetDate(d, m, y); { Restore the system date }
    end;
    [/code]
  • : : I can't find EncodeDate() & DecodeDate() in any Pascal unit,
    : : is it your custom procedure? where is the source??
    : :
    : It isn't a custom procedure, otherwise I would have given the source in my previous post. It's part of the FreePascal DOS unit. In case of TP you need use the SetDate() and GetDate(). Here is a function, which returns the day of the week:
    : [code]
    : function DayOfWeek(Day, Month, Year: word): word;
    : var
    : d, m, y: word;
    : begin
    : GetDate(d, m, y, DayOfWeek); { Save the old system date }
    : SetDate(Day, Month, Year); { Set the new date }
    : GetDate(Day, Month, Year, DayOfWeek); { Get the actual day of the week }
    : SetDate(d, m, y); { Restore the system date }
    : end;
    : [/code]
    :

    i am using Dev-pascal 1.9 and the "getdate" isn't recognised. it works on the TP @ school, but what about for D-P?
  • : : : I can't find EncodeDate() & DecodeDate() in any Pascal unit,
    : : : is it your custom procedure? where is the source??
    : : :
    : : It isn't a custom procedure, otherwise I would have given the source in my previous post. It's part of the FreePascal DOS unit. In case of TP you need use the SetDate() and GetDate(). Here is a function, which returns the day of the week:
    : : [code]
    : : function DayOfWeek(Day, Month, Year: word): word;
    : : var
    : : d, m, y: word;
    : : begin
    : : GetDate(d, m, y, DayOfWeek); { Save the old system date }
    : : SetDate(Day, Month, Year); { Set the new date }
    : : GetDate(Day, Month, Year, DayOfWeek); { Get the actual day of the week }
    : : SetDate(d, m, y); { Restore the system date }
    : : end;
    : : [/code]
    : :
    :
    : i am using Dev-pascal 1.9 and the "getdate" isn't recognised. it works on the TP @ school, but what about for D-P?
    :
    According to my sources you can use the DayOfWeek() function, although I'm not sure, since I don't use dev-pascal myself.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories