This topic is locked

navigate forwards and backwards between weeks

1/7/2014 5:57:53 AM
ASPRunnerPro General questions
K
kleanthis author

Happy New Year <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=21813&image=1&table=forumtopics' class='bbc_emoticon' alt=':D' />
I am facing the following problem. I have a table that holds records by date, and I used the following SQL code to filter and display in the view page only the current week, but this is no satisfied me.
I want to add two buttons, so I can navigate forwards and backwards between weeks.



SELECT

dbo.UsersCa.UsName,

dbo.UsersCa.UsSurname,

dbo.UsersCa.[Position],

dbo.InfoCa.IDCa,

dbo.InfoCa.Description,

dbo.InfoCa.DateField,

dbo.InfoCa.IDUser

FROM dbo.InfoCa

INNER JOIN dbo.UsersCa ON dbo.InfoCa.IDUser = dbo.UsersCa.UsUsername

WHERE (dbo.InfoCa.DateField >= DATEADD(wk, DATEDIFF(wk,0,GETDATE()), -1)) AND (dbo.InfoCa.DateField <= DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 5))

ORDER BY dbo.InfoCa.DateField DESC, ROW_NUMBER()

over(PARTITION by dbo.InfoCa.DateField, dbo.InfoCa.IDUser order by DateField)

K
kleanthis author 1/8/2014



Happy New Year <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=73564&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
I am facing the following problem. I have a table that holds records by date, and I used the following SQL code to filter and display in the view page only the current week, but this is no satisfied me.
I want to add two buttons, so I can navigate forwards and backwards between weeks.



SELECT

dbo.UsersCa.UsName,

dbo.UsersCa.UsSurname,

dbo.UsersCa.[Position],

dbo.InfoCa.IDCa,

dbo.InfoCa.Description,

dbo.InfoCa.DateField,

dbo.InfoCa.IDUser

FROM dbo.InfoCa

INNER JOIN dbo.UsersCa ON dbo.InfoCa.IDUser = dbo.UsersCa.UsUsername

WHERE (dbo.InfoCa.DateField >= DATEADD(wk, DATEDIFF(wk,0,GETDATE()), -1)) AND (dbo.InfoCa.DateField <= DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 5))

ORDER BY dbo.InfoCa.DateField DESC, ROW_NUMBER()

over(PARTITION by dbo.InfoCa.DateField, dbo.InfoCa.IDUser order by DateField)



Anyone with an answer?