Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Combining Text and Date function in VBA

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Combining Text and Date function in VBA

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Combining Text and Date function in VBA

On 6 Oct 2006 14:39:33 -0700, "Pablo" 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Combining Text and Date function in VBA

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advanced text function (combining text) Johan[_2_] Excel Worksheet Functions 2 March 27th 08 10:05 PM
get date function result as text Andrew[_2_] Excel Worksheet Functions 2 February 27th 07 01:37 AM
Date function/Text issue MijC Excel Worksheet Functions 10 December 6th 05 09:34 PM
Combining Text and Date for VLOOKUP biggymismyname Excel Worksheet Functions 2 December 5th 05 04:01 PM


All times are GMT +1. The time now is 03:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"