Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Extract End of week from Date
Tue, Oct 9 2007 7:35 PMPermanent Link

"Adam H."
Hi,

I was wondering if their is an SQL equivalent to the "EndOfTheWeek" function
in the dateutils.pas unit?

(I'm trying to calculate the date of next "Saturday" of any given date).

Thanks & Regards

Adam.
Wed, Oct 10 2007 6:43 AMPermanent Link

Bruno Krayenbuhl

(I'm trying to calculate the date of next "Saturday" of any given date).

var
 Saturday,
 ThisDay : TdateTime;
...


 Saturday := ThisDay - DayOfWeek(ThisDay) + 7;

Note : in SQL Monday is Day 1 of week
         in Delphi Sunday is Day 1 of Week

Bruno

Wed, Oct 10 2007 6:07 PMPermanent Link

"Adam H."
Hi Bruno,

Thanks for your reply. My apologies - I probably should have made myself a
little clearer. I was wondering if there was a DBISam SQL function that may
do this, or should I write one of my own?

Thanks & Regards

Adam.

> var
>  Saturday,
>  ThisDay : TdateTime;
>
>  Saturday := ThisDay - DayOfWeek(ThisDay) + 7;
>
> Note : in SQL Monday is Day 1 of week
>          in Delphi Sunday is Day 1 of Week
>
> Bruno
Wed, Oct 10 2007 6:29 PMPermanent Link

"Robert"

"Adam H." <ahairsub4@pleaseREMOVEme.jvxp.com> wrote in message
news:75C1C19B-9452-4527-A051-9107FAF2B51D@news.elevatesoft.com...
> Hi Bruno,
>
> Thanks for your reply. My apologies - I probably should have made myself a
> little clearer. I was wondering if there was a DBISam SQL function that
> may do this, or should I write one of my own?
>

Write Bruno's code in SQL

Current_Date - extract(dayofweek from current_date) + 6 as Sat

Robert

> Thanks & Regards
>
> Adam.
>
> > var
>>  Saturday,
>>  ThisDay : TdateTime;
>>
>>  Saturday := ThisDay - DayOfWeek(ThisDay) + 7;
>>
>> Note : in SQL Monday is Day 1 of week
>>          in Delphi Sunday is Day 1 of Week
>>
>> Bruno
>

Wed, Oct 10 2007 11:11 PMPermanent Link

"Adam H."
Hi Robert,

> Write Bruno's code in SQL
>
> Current_Date - extract(dayofweek from current_date) + 6 as Sat

Aah - I see - thanks for that.

Cheers

Adam.
Fri, Oct 12 2007 8:37 AMPermanent Link

Dan Rootham
Bruno,

<<  in Delphi Sunday is Day 1 of Week >>

It depends.... because there are two different functions: DayOfWeek and DayOfTheWeek.

From the Delphi 7 Help file:

"DayOfTheWeek is ISO 8601 compliant (where Monday is considered the first day of the week).
To obtain the day of the week where Sunday is considered the first day of the week, use the
DayOfWeek function instead."

Regards,
Dan
Image