cast order by

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I'm migrating some code from MySQL to ACCess

I have a character field that I wish to sort numerically (rather than
alpha numerically), I don't want to change the field type.

In MySQL I do this:

ORDER BY CAST(my_field AS SIGNED)

How is this done in Access?

Jeff
 
Use Val(my_field) to return the numeric value portion of the field.
 
Create a calculated field that recasts the data type in your query and sort
on that.

SortByNum: Clng(Nz([MyTextField],0))

Will change the data type from text to long
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top