Cyri Posted January 5, 2010 Share Posted January 5, 2010 (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 January 5, 2010 by Cyri Link to comment Share on other sites More sharing options...
Developers Jos Posted January 5, 2010 Developers Share Posted January 5, 2010 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 etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Cyri Posted January 5, 2010 Author Share Posted January 5, 2010 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 Link to comment Share on other sites More sharing options...
Developers Jos Posted January 5, 2010 Developers Share Posted January 5, 2010 Something like: $mm = StringRight("0" & $mm,2) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Cyri Posted January 5, 2010 Author Share Posted January 5, 2010 Something like: $mm = StringRight("0" & $mm,2) Thanks again Jos. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now