Excel Date/Day

Please post any questions regarding the program here.

Moderator: 2020vision

Excel Date/Day

Postby Steve Voltage » Sun Jul 25, 2010 10:12 pm

i would like to extract the day from the date in my spreadsheet.

i.e GB / Leic 1st Jun / 14:15 5f Mdn Stks

anyone know how? i can use this formula =TEXT(WEEKDAY(A1), "ddd") to give a number for a day i.e saturday=1 but i need the 1st of june bit from spreadsheet race/date info.

:?
Steve Voltage
 

Postby silver » Sun Jul 25, 2010 10:33 pm

The Get_Word function here -

http://www.ozgrid.com/VBA/extract-words-function.htm

- should be useful.

It will allow you to extract the fourth and fifth blocks of text from the cell contents that you mention in your post.

You'll extract them separately then you'll need to join them together.
silver
 
Posts: 42
Joined: Thu Sep 03, 2009 10:50 am

Postby Steve Voltage » Sun Jul 25, 2010 11:03 pm

silver wrote:The Get_Word function here -

http://www.ozgrid.com/VBA/extract-words-function.htm

- should be useful.

It will allow you to extract the fourth and fifth blocks of text from the cell contents that you mention in your post.

You'll extract them separately then you'll need to join them together.


Thanks silver :)
Steve Voltage
 

Postby osknows » Sun Jul 25, 2010 11:48 pm

Hi Arnold,

Put this code in a MODULE

Code: Select all
Function extractdate(strdate As String)
Dim strarray() As String
Dim intday As Integer

'today's date and day
datenow = DateValue(Now())

'date in string
strarray = Split(strdate, " ")
intday = Replace(Replace(Replace(Replace(LCase(strarray(3)), "st", "", _
vbTextCompare), "nd", "", vbTextCompare), "rd", "", _
vbTextCompare), "th", "", vbTextCompare) * 1

'calculate year variance
Do Until day(datenow) = intday
datenow = datenow + 1
Loop

',7 makes Saturday 1
extractdate = Weekday(CDate(intday & " " & strarray(4) & " " & year(datenow)),7)

End Function


then if your string is in cell A1, in excel use

=extractdate(A1)
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am


Return to Help

Who is online

Users browsing this forum: Bing [Bot] and 26 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.