Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Webpart

  Asked By: Nishita    Date: Feb 17    Category: Sharepoint    Views: 678

im really a newby in this sharepoint stuff, but where i work we
have set an intranet with sharepoint portal server 2003, and they want to show
the birthday of the month, and to see everyone whos birthday is selecting the
month, so i would like to get some help please or examples related to this

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Sridhar Tantry     Answered On: Feb 17

Assuming that you have a sharepoint  list with the information you
want
to display you could do something like the following

DateTime currentDate;
int year, month;
currentDate = System.DateTime.Now;
year = currentDate.Year;
month = currentDate.Month;
DateTime monthStart = new DateTime(year, month, 1);
DateTime monthEnd = monthStart.AddMonths(1).AddDays(-1);
monthEnd = monthEnd.AddHours(23);
monthEnd = monthEnd.AddMinutes(59);
monthEnd = monthEnd.AddSeconds(59);
string queryString = "<Where><Geq><FieldRef Name='BirthDate'/><Value
Type='DateTime'>";
queryString += SPUtility.CreateISO8601DateTimeFromSystemDateTime
(monthStart);
queryString += "</Value></Geq>";
queryString += "<And><Leq><FieldRef Name='BirthDate'/><Value
Type='DateTime'>";
queryString += SPUtility.CreateISO8601DateTimeFromSystemDateTime
(monthEnd);
queryString += "</Value></Leq></And></Where>";
SPQuery query = new SPQuery();
query.Query = queryString;
eventsListFilteredItems = eventsList.GetItems(query);

The builds an SPQuery extracting birthdates that are larger or equal
to
the first of the month (0 hours) and less than or equal to the last
of
the month (23:59 hours)
The last line gets all the list items that fit the filter and gives
you
set  you can enumerate through and do whatever displays, picture
library lookups, etc you may want to do at this point.

 
Didn't find what you were looking for? Find more on Webpart Or get search suggestion and latest updates.




Tagged: