Avatar of Roman F
Roman F
Flag for United States of America asked on

help with conversion

i have a date with data type number  which looks like 20130129 and it should be converted to date 01/29/2013, how can i do that
Microsoft OfficeMicrosoft AccessSQL

Avatar of undefined
Last Comment
Roman F

8/22/2022 - Mon
SOLUTION
dsacker

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
dsacker

If you need to work with it as a real DATETIME field, simply add this:
SELECT CONVERT(datetime, SUBSTRING(CONVERT(varchar(8), MyDateField), 5, 2) + '/' +
       RIGHT(CONVERT(varchar(8), MyDateField), 2) + '/' +
       LEFT(CONVERT(varchar(8), MyDateField), 4)) AS FormattedDate

Open in new window

I know it's a bit lengthy simply to reconstruct it, but you could create a VIEW from the table, adding this derived field, if you need to run reports or queries often.
SOLUTION
David L. Hansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Roman F

ASKER
thank you but none of the examples are working, since the access does not understand the function you gave to me (convert and substring)

i made myself
Left(READ_DT,4) AS [Year],
Mid(READ_DT,5,2) AS [Month],
Mid(READ_DT),7,2) AS [Day],

[Month] & "/" & [Day] & "/" & [Year] AS ReadDate

but i am not sure if its a real date
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23