Avatar of Roman F
Roman FFlag 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
SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of dsacker
dsacker
Flag of United States of America image

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
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
ASKER CERTIFIED SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Roman F
Roman F
Flag of United States of America image

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
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo