TEXT format date to DATE field in query

Hi,

I have taken over an MSSQL database which, for reasons beyond me, dates have been stored in TEXT fields in the following format yyyy.mm.dd time (2017.11.29 16:27:21).  I am working on an Access Query and need to use this field, but convert it to a date format DD/MM/YYYY so that i can query against the date.  How do i format my query field accordingly?

Many thanks,
Anthony
LVL 1
anthonytrAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
try create a View in SQL Server in which you convert that text field into date, like:

select ...
cast(yourDate as datetime) as DateField
...

Open in new window


and then let your Access to query to that View instead.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
anthonytrAuthor Commented:
Hi Ryan,

Is there anyway of doing the convert directly in MS Access Query?
0
ste5anSenior DeveloperCommented:
What SQL Server version?

I would add a computed, persisted column for this.

Also I would try to get that information. Cause it is a mistake. And it should be corrected, it's a technical debt, which will produce further costs. Thus this is the business reason to correct it.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

aikimarkCommented:
Well, you could do any of the following:
* create a SQL Server view of the table where this field is converted
* similar to above, but using a stored proc
* convert the field in an Access query: cdate(replace([yourdateastextfield],".","-"))
0
anthonytrAuthor Commented:
It is a commercial system database from a highly regarded source (I will not name names here - it would be far too embarrassing for them...ha!)

I have created a View in SQL with the correct date format.  When i link this in my Access Database, does the data refresh each time it is opened or queried against?  It doesn't appear like a linked table.

Anthony
0
aikimarkCommented:
If you open it in an ADODB recordset, you might be able to control when you see changes.
I think you will always see changes if you open an Access query
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.