ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Text and Today() function in VBA (https://www.excelbanter.com/excel-worksheet-functions/113266-text-today-function-vba.html)

[email protected]

Text and Today() 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"""


Gary''s Student

Text and Today() function in VBA
 
Sub ppena()
Dim s As String
s = Now()
s2 = Split(s, " ")
sDate = s2(0) & " 00:00:00 AM"
eDate = s2(0) & " 11:59:59 PM"
MsgBox (sDate)
MsgBox (eDate)
End Sub

--
Gary's Student


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




All times are GMT +1. The time now is 04:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com