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 |
|
PingTheServer
Starting Member
28 Posts |
Posted - 2009-01-06 : 13:34:26
|
| I am trying to come up with a select statement to create a view to compare the current YYYY-MM with the stored expiremonth YYYY-MM-DD 00:00:00.000I want to select only the records with a current renew month. My feild "expiremonth" is a datetime.Something like this:select ...., expiremonthfrom ...., BTBoatswhere BTBoats.expiremonth = current YYYY-MMI just dont know the proper syntax to make that comparison. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
PingTheServer
Starting Member
28 Posts |
Posted - 2009-01-06 : 13:55:06
|
quote: Originally posted by tkizer Could you show us a data example as your explanation is not clear?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog
Sure:SELECT BTOwners.name1, BTOwners.mailaddress, BTOwners.mailcity, BTOwners.mailstate, BTOwners.mailzipcode, BTBoats.modelyear, BTBoats.hullmake, BTBoats.hullserialno, BTBoats.fuel, BTBoats.usage, BTBoats.boatlength, BTBoats.class, BTBoats.expiremonth, BTRegFees.mailfeeFROM BTBoats CROSS JOIN BTOwners CROSS JOIN BTRegFees CROSS JOIN BTSalesTaxesWHERE (BTBoats.expiremonth = '2009-01') What I would like is to have this view update itself and show only the current month without me having to hardcode the YYYY-MM in the view. The expiremonth looks like YYYY-MM-DD 00:00:00.000, and I want to select only the current YYYY-MM.So for example, in January, I want the view to show only expiremonth 2009-01. I hope that makes sense. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|
|