Author |
Topic |
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-05-08 : 03:29:50
|
I think this simple. First I would like to know how to get the exact date (today's date)? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-08 : 03:30:56
|
GETDATE() E 12°55'05.25"N 56°04'39.16" |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-05-08 : 03:33:55
|
ok what i want to get the date every 2 weeks. Meaning, it will change after 2 weeks. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-08 : 03:55:29
|
And meanwhile, which date would you like to return? E 12°55'05.25"N 56°04'39.16" |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-05-08 : 03:57:05
|
So run getdate() every 2 weeks. |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-05-08 : 03:58:37
|
yes, preferably Sundays. Like I want to make it stay as May 4 and t will changed after 2nd sunday which is May 18. |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-05-08 : 03:59:18
|
How is that an exact date?Also, what time on that date do you want it to be? |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-05-08 : 04:02:07
|
I have a report and it's being dated every other sundays. Instead of manually entering the date, I want to make it automatic. Like it will change every other week. |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-05-08 : 04:08:13
|
Well, this will get you the previous Sunday:select dateadd(day, 1 - datepart(dw, getdate()), getdate())But you best bet would be to store the date in a table each 2nd Sunday and then use this in your query. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-08 : 04:09:23
|
SELECT DATEADD(DAY, DATEDIFF(DAY, '19000108', GETDATE()) / 14 * 14, '19000107') E 12°55'05.25"N 56°04'39.16" |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-05-08 : 04:13:10
|
ok so this will changed automatically comes may 18? or does it change every day? |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-05-08 : 04:14:10
|
quote: Originally posted by Peso SELECT DATEADD(DAY, DATEDIFF(DAY, '19000108', GETDATE()) / 14 * 14, '19000107') E 12°55'05.25"N 56°04'39.16"
Nice. |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-05-08 : 04:17:56
|
okay i think it work. How about for dates April 20, April 6 and March 23. I would like them to aumatically moved every other sundays. Thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-08 : 04:20:30
|
Try for yourself. How hard is that to do? E 12°55'05.25"N 56°04'39.16" |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-08 : 04:22:25
|
Oh my God! My suggestion returned March 23 for the input date April 6.April 6 for the input date April 20.April 20 for the input date April 23. E 12°55'05.25"N 56°04'39.16" |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-05-08 : 04:23:48
|
not really sure how. Please just last one. Thanks |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-05-08 : 04:25:53
|
It also returns the May 4 when May 18 is input. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-08 : 04:28:18
|
It is a bounding thingy. OP never stated which date to return when input date is a sunday.If you want current sunday to be returned (if a every second sunday), replace '19000108' with '19000107'SELECT DATEADD(DAY, DATEDIFF(DAY, '19000107', GETDATE()) / 14 * 14, '19000107') E 12°55'05.25"N 56°04'39.16" |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-05-08 : 04:28:41
|
Yes but it will be changed on May 19. |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-05-08 : 04:40:56
|
anyone can help? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-08 : 04:47:14
|
quote: Originally posted by cutiebo2t anyone can help?
So you don't appreciate the help and suggestion I have given for free the last hour? E 12°55'05.25"N 56°04'39.16" |
|
|
Next Page
|