Date question

M

Matt

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..
 
E

Evertjan.

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)
 
B

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,379
Messages
2,571,945
Members
48,806
Latest member
LizetteRoh

Latest Threads

Top