ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Extracting Part of a Date (https://www.excelbanter.com/excel-discussion-misc-queries/56732-extracting-part-date.html)

GLT

Extracting Part of a Date
 
Hi,

I have a variable in VBA called myDate and I need to extract the fist two
letter of the day, from the date which is stored in myDate.

For example, if myDate = Tuesday, July 3 2007, then I need to put 'TU' into
variable of myDay.

Can anyone help?

Thanks.

Excelerate-nl

Extracting Part of a Date
 
Maybe this might help (extracted from VBA Help:
Left Function Example
This example uses the Left function to return a specified number of
characters from the left side of a string.

Dim AnyString, MyStr
AnyString = "Hello World" ' Define string.
MyStr = Left(AnyString, 1) ' Returns "H".
MyStr = Left(AnyString, 7) ' Returns "Hello W".
MyStr = Left(AnyString, 20) ' Returns "Hello World".

Regards,

Jan BArt

"GLT" wrote:

Hi,

I have a variable in VBA called myDate and I need to extract the fist two
letter of the day, from the date which is stored in myDate.

For example, if myDate = Tuesday, July 3 2007, then I need to put 'TU' into
variable of myDay.

Can anyone help?

Thanks.


Kleev

Extracting Part of a Date
 
I did the following from the Immediate Pane:

mydate = now()
? mydate
11/22/2005 3:59:29 PM
mydate = ucase(left(weekdayname(weekday(mydate)),2))
? mydate
TU


"GLT" wrote:

Hi,

I have a variable in VBA called myDate and I need to extract the fist two
letter of the day, from the date which is stored in myDate.

For example, if myDate = Tuesday, July 3 2007, then I need to put 'TU' into
variable of myDay.

Can anyone help?

Thanks.



All times are GMT +1. The time now is 10:56 AM.

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