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 |
|
fiesta_donald
Starting Member
4 Posts |
Posted - 2002-03-14 : 12:32:45
|
| I need to create a view that queries a table and returns data from the first of the month and ends on the last day of the month.(i.e.: select * from foo_table where timestamp >= first_day_of_month and timestamp <= last_day_of_month)Does anyone know how to do this? I am having a hard time using getdate and the date functions.thank you,Mark |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-03-14 : 12:45:22
|
| I assume the timestamp is a datetime and not a timestamp datatype.something likewhere timestamp >= convert(varchar(8),dateadd(dd,(datepart(dd,getdate())-1) * -1, getdate()),112)and timestamp < convert(varchar(8),dateadd(mm,1,dateadd(dd,(datepart(dd,getdate())-1) * -1, getdate())),112)==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|