Date Formatting

  • Thread starter Thread starter Jeff S
  • Start date Start date
J

Jeff S

I simply want to format a date that originatges as a string.

Dim strTemp as String
strTemp - "2/6/2003"

I want to format it so that it is "Feb 06", and separately format it to be
"02/06/2003"

Thanks.
 
Hi Jeff,

Below is sample code to convert the format as u needed.

Dim strTemp as String
Dim dtDateTime as DateTime
Dim strTemp1 as String
Dim strTemp2 as String
strTemp = "2/6/2003"
dtDateTime = DateTime.ParseExact(strTemp, "d/M/yyyy", null) ' to convert to
datetime format from string
strTemp1 = dtDateTime.ToString("MMM dd") ' Has value u need ie. "Feb 06"
strTemp2 = dtDateTime.ToString("dd/MMM/yyyy") ' Has value u need ie.
"02/06/2003"

Hope this helps.

Thanks,

sswalia
MCSD, MCAD, OCA
 
Back
Top