×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

extract month to order, from calculated field

extract month to order, from calculated field

extract month to order, from calculated field

(OP)
Hi guys
 
I have a query which returns a calculated field of type date
 
i would like to order my records by the month of that field
 
something like:

  select distinct pe.commencedate, sn.skillid, s.name sname, sn.timeperiodid, tp.weeks, p.name pname, p.companyid, (pe.commencedate + (weeks * 7)) as RequiredBy
from personemployment pe
join person p on p.personid = pe.personid
join skillneeded sn on sn.employmentid = pe.employmentid
left join timeperiod tp on tp.timeperiodid = sn.timeperiodid
join skill s on s.skillid = sn.skillid
where p.companyid = 1
and ((pe.commencedate + (weeks * 7)) >= '3/12/03' and (pe.commencedate + (weeks * 7)) <= '3/12/04')
and sn.skillid not in
(select skillid from skillattempt where (personid = p.PersonID and skillid = sn.skillid
and result = 'P' and (validto is null or validto > '3/12/03')))
                order by extract(month from 8)
 

only firebird1.0 doesnt like extract there.  is there a way i can do this?
 
Tracey
Software Developer / Web Master
Logis
tracey@logis.co.nz
(025) 213-1065

RE: extract month to order, from calculated field

Hi!

Put the 'extract(...' into the start of the select statement (to simplify the 'order') and use the field number only in the 'order'.

select distinct extract(month from (pe.commencedate+(weeks*7))), ...
order by 1

Otto

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close