View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Combining Text and Date function in VBA

On 6 Oct 2006 14:20:34 -0700, "Pablo" wrote:

Here is a piece of my code. It will not compile.
I want SDate to be a text string in the format of "8/10/06 00:00:00 AM"
and EDate "8/10/06 11:59:59 PM". I preffered if this values were
yesterday's dates, but they have to change daily. Any suggestions?
Thanks.

My Code:

Dim SDate As String
Dim EDate As String

Set SDate = "TEXT(Month(TODAY())&" / "&DAY(TODAY())&" / "&Year(today())
& ""00:00:00 AM"""
Set SDate = "TEXT(Month(TODAY())&" / "&DAY(TODAY())&" / "&Year(today())
& ""11:59:59 PM"""


Not sure what you want to do with these, but you need to have a triple
double-quote before the time section in order to compile.

e.g. """00:00:00 AM"""


--ron