Results 1 to 3 of 3
  1. #1
    kestefon is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    108

    Convert Text String to Date in SQL

    I want to run a query that will convert a field of text to dates. All of the text entries are in the following format: "JUL01/13" and I'd like the query result to show the actual date value of 7/1/13. In Excel I would do this by using LEFT/MID/RIGHT functions and some concatenation...is there an equivalent (or an easier way) in Access SQL?

    On a related note, I'd also like to do the reverse (this would be for a different table). I'd like to take the date of 7/1/13 and express the month as text (i.e. "July").

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Code:
    CDate(Left([testdate],3) & "/" & Mid([testdate],4,2) & Right([testdate],3))
    assuming your date is always 3 letters for the month, 2 digits for the day and 2 digits for the year.

    Code:
    MonthName(DatePart("m",[testdateconv]),True)
    where testdateconv would be your actual date

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    The list of most common functions is here http://www.techonthenet.com/access/functions/
    Something like these should work:
    Code:
    DateValue(Mid(MyText,1,3) & " " & Mid(MyText,4,2) & " 20" & Mid(MyText,7,2))
    
    MonthName(Month(MyDate))

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 09-11-2013, 09:49 AM
  2. How to convert Date to String?
    By thebaul in forum Access
    Replies: 1
    Last Post: 08-01-2012, 05:51 AM
  3. Replies: 4
    Last Post: 06-19-2012, 12:41 PM
  4. Query to convert String to Date??
    By taimysho0 in forum Programming
    Replies: 3
    Last Post: 06-04-2012, 04:48 PM
  5. Convert string to date
    By ~SwAmPdOnKeY~ in forum Queries
    Replies: 4
    Last Post: 09-11-2008, 07:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums