Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sql views and dates

Posted on 2013-06-26
4
Medium Priority
?
226 Views
Last Modified: 2013-07-15
I have an sql view that I display on sharepoint using sharepoint data sources.

The field in my SQL view that I want to share is order by is called [date recorded]

The field date recorded is a datetime field and is stored using American formatting as that is the sql server default.

I can get the dates in british format by using this CONVERT(nvarchar, dbo.tblcustomerdetails.[Date Recorded],103 ) however then I cant order by the date as it is no longer a date.

If I try CONVERT(date, dbo.tblcustomerdetails.[Date Recorded],103 ) it still displays as American format.

Is there a way through either the SP data sources or SQL that I can get this to be a date still but displayed in English format.
0
Comment
Question by:CaptainGiblets
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 49

Expert Comment

by:PortletPaul
ID: 39277291
IF it really is a datetime field:
>>field date recorded is a datetime field and is stored using American formatting
sorry, that's not a correct impression
datetime information is stored as 2 integers - it is never stored by the format
what you 'see' isn't what is stored

you do NOT need to convert at all to properly order by that datetime field

select
-- use a format here to 'display' it in the fashion wanted
convert(varchar, thatField, 121) as displayDate -- 103, your choice
...
from whatever
order by
 thatField -- no conversion required here
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 39277292
IF you are removing 'time' as part of the logic

select
-- use a format here to 'display' it in the fashion wanted
convert(varchar, thatField, 121) as displayDate -- 103, your choice
...
from whatever
order by
  -- no conversion required here
dateadd(day, datediff(day,0, [thatField] ), 0) -- use date functions to remove the time
0
 
LVL 6

Author Comment

by:CaptainGiblets
ID: 39277295
I have tried converting to varchar but then sharepoint will only treat it as a string.
0
 
LVL 49

Accepted Solution

by:
PortletPaul earned 2000 total points
ID: 39277314
@CaptainGiblets sorry - didn't look at the asker's name - I just jumped in
(it's a hot button for me: the impression that dates are stored in a format)

I have to admit I really only know SharePoint as an end-user but:
 
try this?

convert(date,[thatField]) -- removes time
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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.

688 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