Solved

Date output format must NOT be converted to CHAR of any kind

Posted on 2011-03-08
3
299 Views
Last Modified: 2012-05-11
Hi All

I have a table where the dateformat is stored in a INT field (A Cisco CDR table).

I can convert the date to a more readable format via this conversion:

SELECT CONVERT(varchar(11), (DATEADD(hh, 2, DATEADD(s, dateTimeConnect, '19700101'))), 105) +' '+ CONVERT(varchar(11), (DATEADD(hh, 2, DATEADD(s, dateTimeConnect, '19700101'))), 108)  AS start, FROM dbo.cdrdata

The output will look like this on my HTML (asp) page: 13-07-2010 (dd-mm-yyyy plus the stored TIME as well - the preferred dateformat in denmark).

My problem is that I'm not able to ORDER BY these dates since they are in some soft of CHAR format and not DATE format.

Is there another type of conversion where I get to keep the date format or is there another kind of order type where I get to list the dates ordered as dates?
0
Comment
Question by:jensjakobsen
3 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
Comment Utility
You can:
Do your order on SQL Server by your original field
convert them into a date datatype which can sort app side.
0
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
Comment Utility

SELECT CONVERT(varchar(11), (DATEADD(hh, 2, DATEADD(s, dateTimeConnect, '19700101'))), 105) +' '+ CONVERT(varchar(11), (DATEADD(hh, 2, DATEADD(s, dateTimeConnect, '19700101'))), 108)  AS start,
FROM dbo.cdrdata
order by dateTimeConnect
0
 
LVL 1

Author Closing Comment

by:jensjakobsen
Comment Utility
very precise
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now