zero is omitted while converting integer to string - page 2

To add comments, please log in or register
jaffer wilson
921
jaffer wilson  
Marco vd Heijden:

Please don't get fooled by people telling you that 'there is only one way'.

In the end all that matters is that your code does what you designed it to do, and that it (hopefully) pay's off.

How you got there is less important then getting there.

There are many many ways to make something work.

If someone claims that there is only one way to the top, it shows a very narrow mindset. 

In stead try all things that you can come up with and pick the one that performs best.

The other attempts will come in handy when you try to solve other problems in the future.

Thank you for inspiring me sir. With your words and your previous help I tried to figure it out what another way I could  try and I did. See I have done the following:  

string currenttime = TimeToString(TimeCurrent())+":00";
   StringReplace(currenttime,".","-");

This gave me result and everything worked fine, thank god.

nicholi shen
2176
nicholi shen  
Marco vd Heijden:

Please don't get fooled by people telling you that 'there is only one way'.

In the end all that matters is that your code does what you designed it to do, and that it (hopefully) pay's off.

How you got there is less important then getting there.

There are many many ways to make something work.

If someone claims that there is only one way to the top, it shows a very narrow mindset. 

In stead try all things that you can come up with and pick the one that performs best.

The other attempts will come in handy when you try to solve other problems in the future.

This would be a very inspirational message for many different topics, but here we're discussing computer science theory, and in CS a datetime is a data-type that represents a linear value and a string is an abstract type that represents data in human readable form or an intermediary such as in this case. You wouldn't tell someone to compare numbers by using their string values

if("2" > "1")

so why would you encourage bad form by saying it's perfectly ok to compare a potentially inconsistent string representation of a date? I don't normally agree with whroeder, but he's absolutely correct in this case. If you're comparing numbers (which datetime is) then you first need to convert that string to a number. 

Marco vd Heijden
Moderator
8428
Marco vd Heijden  

I'm not going to bite.

Sorry.

12
To add comments, please log in or register