Date question
am 24.02.2007 19:18:38 von mwagoner
I have a form field area that I need to always have display the
upcoming thursday date. ie. this week I would need the form field
area to display 3/1/2007. Then beginning on the Friday 3/2/07 i need
it start displaying 3/8/2007. any suggestions..
Re: Date question
am 24.02.2007 20:41:04 von exjxw.hannivoort
Matt wrote on 24 feb 2007 in microsoft.public.inetserver.asp.general:
> I have a form field area that I need to always have display the
> upcoming thursday date. ie. this week I would need the form field
> area to display 3/1/2007. Then beginning on the Friday 3/2/07 i need
> it start displaying 3/8/2007. any suggestions..
Form fields are for client input, methinks,
so what you "need" could not be what you want.
vbscript:
theDate = Date()
n = 5 - weekday(theDate)
if n<0 then n = n + 7
nextThursday = dateAdd("d",n,theDate)
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Re: Date question
am 24.02.2007 21:06:56 von Dave Anderson
"Matt" wrote:
> I have a form field area that I need to always have display
> the upcoming thursday date. ie. this week I would need the
> form field area to display 3/1/2007. Then beginning on the
> Friday 3/2/07 i need it start displaying 3/8/2007.
Then you would probably be interested in the Weekday Function:
http://msdn.microsoft.com/library/en-us/script56/html/c6c8d3 d6-cf6b-4545-8844-2b09a72491bd.asp
Here's a VBScript function that will produce the requested "next thursday":
Function NextThursday(d)
NextThursday = DateAdd("d",7-Weekday(d,6),d)
End Function
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Re: Date question
am 24.02.2007 21:49:33 von Bob Lehmann
This could probably be refined more, but for SQL Server, and first day of
week set to Sunday -
declare @day_of_week int
declare @days_left_in_week int
declare @cut_off int
declare @next_day int
select @day_of_week = DATEPART(dw, GETDATE())
select @days_left_in_week = 7 - @day_of_week
select @cut_off = 6 -- Friday
select @next_day = 5 -- Thursday
if @day_of_week >= @cut_off
begin
select getdate() + @next_day + @days_left_in_week
end
else
begin
select getdate() + @next_day - @day_of_week
end
-- end if
Bob Lehmann
"Matt" wrote in message
news:1172341118.337311.111690@p10g2000cwp.googlegroups.com.. .
> I have a form field area that I need to always have display the
> upcoming thursday date. ie. this week I would need the form field
> area to display 3/1/2007. Then beginning on the Friday 3/2/07 i need
> it start displaying 3/8/2007. any suggestions..
>