We help IT Professionals succeed at work.

Retrieve SQL Date only not time

Medium Priority
573 Views
Last Modified: 2012-05-12
Dear experts,

The attached query retrieves 'Start Date' in SQL BIDS from a SharePoint 2010 list. This field contains a date + time string. I only want to retrieve the date, not the time, is this possible?

 
<RSSharePointList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ListName>TimeTracker</ListName>
  <ViewFields>
    <FieldRef Name="StartDate" />
  </ViewFields>
</RSSharePointList>

Open in new window

Comment
Watch Question

Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009
Commented:
date time article (for sql server):
http://www.experts-exchange.com/A_1499.html

for the sharepoint part, I have no idea, though ...
Top Expert 2011
Commented:
If you add this to your query, you get date only:
Select  Right('0' + Cast(Month(getdate()) as Varchar(2)),2) +'/'+
Right('0' + Cast(Day(getdate())as Varchar(2)),2) + '/'+
cast(Year(getdate()) as char(4)) as StartDate

How you use that in sharepoint, I don't know, sorry
Christopher GordonSenior Developer Analyst
Commented:
-- Date Only Format

select CAST(getdate() as date) as Date_Only

Explore More ContentExplore courses, solutions, and other research materials related to this topic.