PC Review


Reply
Thread Tools Rate Thread

Combining Text and Date function in VBA

 
 
Pablo
Guest
Posts: n/a
 
      6th Oct 2006
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"""

 
Reply With Quote
 
 
 
 
Ron Rosenfeld
Guest
Posts: n/a
 
      6th Oct 2006
On 6 Oct 2006 14:20:34 -0700, "Pablo" <(E-Mail Removed)> 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
 
Reply With Quote
 
Pablo
Guest
Posts: n/a
 
      6th Oct 2006
I added the quotation mark and still doesn't compile.
I am using this to querry a database that is online. I am trying to
populate some fields so I can automate the generation of a daily
report.

I tried this variant but still does not work...Thanks for your help.

Dim SDate As String
Dim EDate As String

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


Ron Rosenfeld wrote:
> On 6 Oct 2006 14:20:34 -0700, "Pablo" <(E-Mail Removed)> 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


 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      6th Oct 2006
On 6 Oct 2006 14:39:33 -0700, "Pablo" <(E-Mail Removed)> wrote:

>I added the quotation mark and still doesn't compile.
>I am using this to querry a database that is online. I am trying to
>populate some fields so I can automate the generation of a daily
>report.
>
>I tried this variant but still does not work...Thanks for your help.
>
>Dim SDate As String
>Dim EDate As String
>
>Set SDate = "TEXT(Month(TODAY(),mm)&" / "&DAY(TODAY(),dd)&" /
>"&Year(today(),yy) & """"00:00:00 AM"""
>Set SDate = "TEXT(Month(TODAY(),mm)&" / "&DAY(TODAY(),dd)&" /
>"&Year(today(),yy) & """"11:59:59 PM"""


Now you have 4 double quotes. Proper syntax is for three.

What do you mean by "does not work"?
--ron
 
Reply With Quote
 
Pablo
Guest
Posts: n/a
 
      7th Oct 2006
I found a way to work around it. I put the text I wanted into a cell
and them asigned the cellvalue to the variable. THANKS

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"""


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advanced text function (combining text) Johan Microsoft Excel Worksheet Functions 2 27th Mar 2008 10:05 PM
Combining Text and Date srm Microsoft Outlook Form Programming 0 19th Jun 2006 07:01 PM
Combining Text and Date Values =?Utf-8?B?S2F0aGVyaW5lIFI=?= Microsoft Access 2 14th Dec 2005 04:00 PM
Combining Text and Date for VLOOKUP biggymismyname Microsoft Excel Worksheet Functions 2 5th Dec 2005 04:01 PM
combining date and text fields into text field Kennedy Microsoft Access Queries 2 2nd Aug 2004 11:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:41 PM.