?
Solved

Date Field - Only want to return values for the first of the month

Posted on 2005-05-02
6
Medium Priority
?
232 Views
Last Modified: 2010-03-19

I have a field in a table (Run Date) (Small date type) and it gets populated everyday from a dts package.  

I just want to run the values for the first of every month...5/1/2004, 4/1/2005....

how can this be done?
0
Comment
Question by:SamirKumar
  • 3
  • 2
6 Comments
 

Author Comment

by:SamirKumar
ID: 13912718
correction...

i want a query to run only the values for the first of the month....i want hte package to run everyday...
0
 
LVL 11

Expert Comment

by:Jokra_the_Barbarian
ID: 13912797
You can either use a datepart in your query:  where datepart(d,rundate) = 1
or
create a time dimension table that holds the dates that you want, then do a join on rundate.

0
 
LVL 13

Expert Comment

by:ispaleny
ID: 13912802
If there is an unique column id:

select A.*
from YourTable A
join
(
select min(id) mid
from YourTable
group by convert(char(6), [Run Date],112)
) X on A.id=X.mid
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:ispaleny
ID: 13912816
The first of every month = the first record in the month or the first day of the month?
0
 

Author Comment

by:SamirKumar
ID: 13913141
i need the first day of the month....

4/1
5/1
6/1

can htis be done in one statement and no additional tables...
0
 
LVL 13

Accepted Solution

by:
ispaleny earned 200 total points
ID: 13913195
Jokra_the_Barbarian already post a where condidition you can use.

select * from YourTable
where datepart(d,[Run Date]) = 1
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question