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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 date time help

Author  Topic 

blackX
Posting Yak Master

102 Posts

Posted - 2008-04-07 : 15:18:54
I need to update a field with the Friday after the current days day. So if I were to run in today it should put in 4/11/08, next saturday it should put in 4/18/08. Any help would be great.

my query would look something like this...

update repcommission set paydate = (need help here) where ...


thanks

bbasir
Yak Posting Veteran

76 Posts

Posted - 2008-04-07 : 17:10:20
you can always use the dateadd function in sql server and add days to teh current date. take a look at dateadd function and also at datepart function if your column is not in the exact date format.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-04-07 : 17:26:52
Like Dateadd(day,7,getdate())
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-08 : 00:59:07
So spoke Zarathustra...

DATEADD(DAY, (DATEADD(DAY, '19000101', GETDATE()) / 7) * 7, '19000105')



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-08 : 03:32:52
quote:
Originally posted by Peso

So spoke Zarathustra...

DATEADD(DAY, (DATEADD(DAY, '19000101', GETDATE()) / 7) * 7, '19000105')



E 12°55'05.25"
N 56°04'39.16"



Something goes wrong

Server: Msg 8116, Level 16, State 1, Line 1
Argument data type varchar is invalid for argument 2 of dateadd function.


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-08 : 03:36:32
quote:
Originally posted by Peso

So spoke Zarathustra...

DATEADD(DAY, (DATEADD(DAY, '19000101', GETDATE()) / 7) * 7, '19000105')



E 12°55'05.25"
N 56°04'39.16"



I think you meant this


select DATEADD(DAY, (DATEDIFF(DAY, '19000101', GETDATE()) / 7) * 7, '19000105')

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-08 : 03:56:45
Madhi is right, I posted a sloppy answer.


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -