DenaliHardtail
DenaliHardtail

Reputation: 28306

DateTime from custom datetime string: Mid() has too many parameters?

In the formula below I'm trying to convert a custom date string (yyyymmddhhmmss) into a date (date, not datetime). When I try to save the following I get an error message that states "too many arguments have been given to this function" and both Mid statements are highlighted. The CR IDE shows an overload for Mid that accepts three parameters. I rewrote the formula from scratch a few times to no avail. Any suggestions?

CDate (Left({ABC.ArrivalDT},4),Mid({ABC.ArrivalDT},5,2),Mid({ABC.ArrivalDT},8,2))

Upvotes: 1

Views: 1648

Answers (2)

craig
craig

Reputation: 26262

DateValue({ABC.ArrivalDT}[1 to 4] + "/" + {ABC.ArrivalDT}[5 to 6] + "/" + {ABC.ArrivalDT}[7 to 8])

Upvotes: 1

DenaliHardtail
DenaliHardtail

Reputation: 28306

okay, here's a solution that works. I also changed my mind and decided to go for a datetime, not just a date as stated in my original post.

CDateTime (
    CDate (
    tonumber(Left({ABC.ArrivalDT},4)),
    tonumber (Mid({ABC.ArrivalDT},5,2)),
    tonumber (Mid({ABC.ArrivalDT},7,2))
    )
,
    CTime (
    tonumber (Mid({ABC.ArrivalDT},9,2)),
    tonumber (Mid({ABC.ArrivalDT},11,2)),
    00
    )
)

Upvotes: 0

Related Questions