CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 ORDER BY question

Print topic Send  topic

Author Message
pr3mium

Posts: 31
Posted: 02/22/2004, 11:17 PM

I have a birthday field in my employees table, but it's in the form of YYYYMMDD (generated from Social security number). How could I do the ORDER BY '%DD' or something like that? I query this month's birthdays and would like to order the results by the day.

I've heard of the CONVERT function in SQL - can I use this to somehow convert the field to datetime while querying?
Any ideas would be highly appreciated.

Thanks
View profile  Send private message
pr3mium

Posts: 31
Posted: 02/22/2004, 11:36 PM

Sorry for bothering, after some research I used the following query:
  
SELECT DISTINCT name,birth,DATEPART(dd, birth) FROM emp_view  
WHERE birth LIKE '____02__'  
ORDER BY DATEPART(dd, birth)  
View profile  Send private message
DonB
Posted: 02/23/2004, 11:53 AM

I would highly recommend storing the date parts you are interested in as
their own columns in the table so you can properly index them. A 'LIKE'
forces a table-scan (all records are read and compared).

You will be fine for a small amount of rows, but will suffer greater
overhead as the number increases.

--
DonB

http://www.gotodon.com/ccbth


"pr3mium" <pr3mium@forum.codecharge> wrote in message
news:64039ad84c28d2@news.codecharge.com...
> Sorry for bothering, after some research I used the following query:
>
  
> SELECT DISTINCT name,birth,DATEPART(dd, birth) FROM emp_view  
> WHERE birth LIKE '____02__'  
> ORDER BY DATEPART(dd, birth)  
> 
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.