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.
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. |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-07 : 17:26:52
|
Like Dateadd(day,7,getdate()) |
 |
|
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" |
 |
|
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 wrongServer: Msg 8116, Level 16, State 1, Line 1Argument data type varchar is invalid for argument 2 of dateadd function.MadhivananFailing to plan is Planning to fail |
 |
|
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 thisselect DATEADD(DAY, (DATEDIFF(DAY, '19000101', GETDATE()) / 7) * 7, '19000105')MadhivananFailing to plan is Planning to fail |
 |
|
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" |
 |
|
|
|
|
|
|