STILL ON DATE transform

User avatar
sal21
PlatinumLounger
Posts: 4402
Joined: 26 Apr 2010, 17:36

STILL ON DATE transform

Post by sal21 »

VALORE="Il file è aggiornato al 7 febbraio 2024."

I i need to transform in (mydate as date) 07/02/2024

VALORE as strng dim

naturally i can have also:

31 dicembre 2024
3 marzo 2024

ecc...

On your last post...

is this correct:

Code: Select all

Private Sub DATA_GMT(VALORE)

    'DATA_GMT
    Dim V() As String, DATA_AGG As Date
    Dim D As Long, M As Long, Y As Long
    V = Split(VALORE)
    D = V(0)
    M = (InStr("gennaiofebbraiomarzoaprilemaggiogiugnoluglioagostosettembreottobrenovembredicembre", V(1)) + 2) \ 4
    Y = V(2)
    DATA_AGG = DateSerial(Y, M, D)
    'DATA_GMT

End Sub

User avatar
HansV
Administrator
Posts: 78794
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: STILL ON DATE transform

Post by HansV »

Does this work?

Code: Select all

    Dim strDate As String
    strDate = Mid(VALORE, InStrRev(VALORE, " al ") + 4)
    strDate = Replace(strDate, ".", "")
    MyDate = DateValue(strDate)
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4402
Joined: 26 Apr 2010, 17:36

Re: STILL ON DATE transform

Post by sal21 »

HansV wrote:
18 May 2024, 17:41
Does this work?

Code: Select all

    Dim strDate As String
    strDate = Mid(VALORE, InStrRev(VALORE, " al ") + 4)
    strDate = Replace(strDate, ".", "")
    MyDate = DateValue(strDate)
GREAT!
TKS