How to convert to date format?

Using Access 2003

Date Column type - text

Table 1

date

20090528
20090529
20090530
20090502
20090504

      

Expected Result

28-May-2009
29-May-2009
30-May-2009
02-May-2009
04-May-2009

      

...

How do I make a query for the format of the expected output date?

+2


source to share


3 answers


As VBA code - you can wrap it as a function

Dim strMyDate As String
Dim dteDate As Date

strDate = "20090528"
dteDate = DateSerial(Left(strDate, 4), Mid(strDate, 5, 2), Right(strDate, 2))
MyStr = Format(dteDate, "dd-mmm-yyyy")
Debug.Print MyStr

      



As a data type in a table . If you add data to a table where the field is Date / Time formatted you can specify the format in the form / table i.e. at the exit.

+3


source


I find that Cdate doesn't work for me.



Format(DateSerial(Left(Field1, 4), Mid(Field1, 2, 2), Right(Field1, 2)), "dd-mmm-yyyy")

      

+1


source


CDate should do what you want ...

0


source







All Articles