Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 Generate Weekday Date Only! HELP!

Author  Topic 

kshinningstr
Starting Member

24 Posts

Posted - 2005-08-01 : 10:08:17
Hello Everyone,
Is there a way to generate only Weekday Date only?

For example, I am creating a ASP application that runs reports for previous business day. If today is Monday, I need to generate Friday's date.
As of right now, I can only generate previous day's date with the following:
tmp_rcn_dt = DateAdd("d", -1, Date())

Thanks!

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-01 : 10:20:50
put something like this (it's just descriptive code) in a function:

function AddSubtractDay(CurrentDate, IsPlus)
if CurrentDate = 'Monday' then
if IsPlus then
CurrentDate = DateAdd("d", 1, Date())
else
CurrentDate = DateAdd("d", -3, Date())
end if
else if CurrentDate = 'Friday'
if IsPlus then
CurrentDate = DateAdd("d", 3, Date())
else
CurrentDate = DateAdd("d", -1, Date())
end if
else
if IsPlus then
CurrentDate = DateAdd("d", 1, Date())
else
CurrentDate = DateAdd("d", -1, Date())
end if
end if
AddSubtractDay = CurrentDate
end function


Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -