UNIX Date

  • Thread starter Thread starter David Chavez
  • Start date Start date
D

David Chavez

Does anyone know how to convert a date in the cyymmdd
format to mmddyyyy?

Thank
David Chavez
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you're using Access/VB use the Format() function:

strDate = Format(strCYYMMDD, "mmddyyyy")

strCYYMMDD contains the date string in cyymmdd format.


If you're using SQL use the CAST() or CONVERT() functions. The
following examples assume the ColumnName column contains the date
formatted as string values "CYYMMDD."

CONVERT(VARCHAR, CONVERT(DATETIME, ColumnName), 101) -> mm/dd/yyyy

CONVERT(VARCHAR, CONVERT(DATETIME, ColumnName), 110) -> mm-dd-yyyy


If, in fact, the column data type was DateTime then the solution would
be:

CONVERT(VARCHAR, ColumnName, 101) -> mm/dd/yyyy -- etc.

If you don't want the punctuation in the date string you'll have to use
the SUBSTRING & concatenation functions. See the SQL Books on Line
(BOL) for info on those functions.

BTW, cyy = yyyy 'cuz c = century number and the first 2 y's on yyyy
represents the century number.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQJBR7YechKqOuFEgEQLUiACfdRXCkvLyzvSVK8qFjPmDUAtzRLAAn3Zu
/ruiprfVof/JrEo1pg2nIfQv
=U6OH
-----END PGP SIGNATURE-----
 
Great, it worked!

Thanks
David Chavez
-----Original Message-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you're using Access/VB use the Format() function:

strDate = Format(strCYYMMDD, "mmddyyyy")

strCYYMMDD contains the date string in cyymmdd format.


If you're using SQL use the CAST() or CONVERT() functions. The
following examples assume the ColumnName column contains the date
formatted as string values "CYYMMDD."

CONVERT(VARCHAR, CONVERT(DATETIME, ColumnName), 101) -> mm/dd/yyyy

CONVERT(VARCHAR, CONVERT(DATETIME, ColumnName), 110) -> mm-dd-yyyy


If, in fact, the column data type was DateTime then the solution would
be:

CONVERT(VARCHAR, ColumnName, 101) -> mm/dd/yyyy -- etc.

If you don't want the punctuation in the date string you'll have to use
the SUBSTRING & concatenation functions. See the SQL Books on Line
(BOL) for info on those functions.

BTW, cyy = yyyy 'cuz c = century number and the first 2 y's on yyyy
represents the century number.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQJBR7YechKqOuFEgEQLUiACfdRXCkvLyzvSVK8qFjPmDUAtzR LAAn3Zu
/ruiprfVof/JrEo1pg2nIfQv
=U6OH
-----END PGP SIGNATURE-----




.
 
Back
Top