1

I have the following query in MS Access

SELECT CREAT.Subject, CREAT.CREAT, (IIf([CREAT.TargetDays]=".",".",Val([CREAT.TargetDays])*24)) AS TargetDays
FROM CREAT
WHERE IsNumeric(CREAT.TargetDays) AND IsNumeric(CREAT.CREAT)
ORDER BY Subject, Val([CREAT.TargetDays]);

I would like to check if a field called FolderName is a string like D18, D1 etc.. which means the first character should be 'D' which is immediately followed by digits. Could someone please tell me how to accomplish this.

1 Answer 1

2

Try this

[FolderName] Like 'D[0-9]*'
Sign up to request clarification or add additional context in comments.

4 Comments

i've mistaken. must be Like 'D[0-9]*'
Yes that worked. Now I hav e string like 'Day 2', 'Day 21', 'Day 10 -Observational Cohort', how can I get strings that are like 'Day' and followed by only digits. In my example, it should return only 'Day 2', 'Day 21' and also in the select query I want to extract the numbers 2 from 'Day 2' and 21 from 'Day 21'. How to accomplish this? It would be great if you could help me with this.
You could probably do it with 'D#' as well. [0-9] will only look for 1 single digit. and * for any character. # will allow more than 1 digit, but digits only. According to: support.office.com/pt-pt/article/…
if you have 'Day' then space, then number , then anything unnecessary and want to extract number - try this: val(mid([FolderName],5))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.