Link to home
Start Free TrialLog in
Avatar of bradderick
bradderickFlag for Australia

asked on

Adding days to a date then sorting by the new date

Hi All,

I'm having some trouble figuring out how to sort by a date which is not stored in the database but which is calculated on-the-fly on my webpage by adding a number of days to another date.

So we have the following fields in the table UserDetails:

Date (smalldatetime ('dd/mmyyyy')
Term (int)

I am trying to sort my results by DueDate (which is dynamically calculated and not stored as a field in the db) which is Date ('dd/mm/yyyy') + Term (number of days (int) ).

So I am wondering if there is anyway that inside my SELECT in my SQL statement I can actually create a new date AS DueDate which is the above sum?

Anyone have any ideas?

Cheers,
Brad
ASKER CERTIFIED SOLUTION
Avatar of Colosseo
Colosseo
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bradderick

ASKER

Thanks Scott! That worked really well and the ORDER BY worked using the alias DueDate as well.

It seems so simple :o) I really appreciate your help.

Cheers,
Brad
Your welcome, glad it worked for you and thanks for the grade

Cheers

Scott