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 |
VJG
Starting Member
17 Posts |
Posted - 2013-10-10 : 14:53:16
|
Guys, I need some guidance: I'm trying to, depending on the current date, select the correct marking period. Right now I'm having to manually enter the dates for that marking period. I'm trying to figure out a way to do this automatically.This is what i have so far, but I'm not sure I'm even going in the right direction. declare @SD char(3)select @SD = (casewhen GETDATE() between start_date and end_date then marking_period end)from REG_MP_DATESwhere MARKING_PERIOD = @SDbelow is a screen print of the table.. What am i missing? This piece of data will be part of a bigger script. How do i refer to it in a script? many Thanks! |
|
tm
Posting Yak Master
160 Posts |
Posted - 2013-10-10 : 15:34:03
|
Try ..DECLARE @SD CHAR(3)SELECT TOP 1 @SD = MARKING_PERIODFROM REG_MP_DATESWHERE START_DATE <= CAST(GETDATE() AS DATE) AND END_DATE >= CAST(GETDATE() AS DATE) |
|
|
VJG
Starting Member
17 Posts |
Posted - 2013-10-10 : 17:30:50
|
Thanks for the help, From what you gave me i was able to develop it to what i was looking for!! thanks again!quote: Originally posted by tm Try ..DECLARE @SD CHAR(3)SELECT TOP 1 @SD = MARKING_PERIODFROM REG_MP_DATESWHERE START_DATE <= CAST(GETDATE() AS DATE) AND END_DATE >= CAST(GETDATE() AS DATE)
|
|
|
|
|
|