View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Date format text conversion

I am trying to convert the current date in to a four digit date ex:
Jan 3 = 0103
Jan 4 = 0104 etc

What I get instead is 103 or 104 etc. If i go to another cell and use
=text(cell,"mmdd") I get the desired result or format the cell for text.
Unfortunately those are not options. Perhaps it's my approach. Here is what I
am using in my attempts:

Dim sdte As Date
Dim dv As String
sdte = Date
Range("D2").Value = Format(sdte, "mmdd")
Range("e2").Value = sdte

dv = DateValue(sdte)
Range("f3").Value = dv
Range("e4").Value = Format(dv, "mmdd")
Range("E6").Value = CDate(dv)

I have also tried Now()

I have also tried "mmmdd" and "0000" in the formats these give me results of
a different date because of the datevalue / system date (39450) any help is
greatly appreciated. Thanks