Extracting Part of a Date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top