Solved

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

Posted on 2011-03-08
3
302 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
ID: 35069609
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
ID: 35069627

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
ID: 35107892
very precise
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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