Sign in to follow this  
Followers 0
Cyri

_DateTimeSplit strips leading 0

5 posts in this topic

#1 ·  Posted (edited)

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



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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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

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  
Followers 0