Jump to content
Sign in to follow this  
Cyri

_DateTimeSplit strips leading 0

Recommended Posts

Cyri

Why does _DateTimeSplit() strip off the leading 0 on the month and day? Almost all the other date functions use dd and mm. Why not the split?

Edited by Cyri

Share this post


Link to post
Share on other sites
Jos

Why does _DateTimeSplit() strip off the leading 0 on the month and day? Almost all the other date functions use dd and mm. Why not the split?

This is because this UDF is designed to calculate with the date and time values.

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Cyri

This is because this UDF is designed to calculate with the date and time values.

Jos

I just wasn't expecting it is all. If I pass in 05 for the month I would expect the result to be 05 and not 5. I just looked at the function in Date.au3 and I see now why it doesn't. By the way, what's the easiest way to pad with a 0 in that case? Check the length?

_DateTimeSplit("2007/05/07", $aDate, $aTime)
If StringLen($aDate[2]) < 2 Then
    $aDate[2] = "0" & $aDate[2]
EndIf
If StringLen($aDate[3]) < 2 Then
    $aDate[3] = "0" & $aDate[3]
EndIf

Share this post


Link to post
Share on other sites
Cyri

Something like:

$mm = StringRight("0" & $mm,2)

Thanks again Jos.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×