Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,
In a value1 column i have values like 9h , value2 column value is -4h10m , i need this all values to be converted into minutes for examples 2h means report has to show 120 m and -4h10m report has to show -250m


please send me the answer with explanation as soon as possible
Posted
Updated 10-Jun-15 21:44pm
v2
Comments
CHill60 11-Jun-15 3:42am    
What have you tried?
What datatype are the columns?

1 solution

Don't do that.
Change your database to either store a number of hours and a number of minutes, or just a number of minutes. And either way, don;t store numeric values in string based fields - they always cause hassle later on when you want to do anything useful with them, as you are starting to see.

Always store data in it's most appropriate types: Dates and times in DATE or DATETIME, numeric values in numeric fields. using string based storage is simple to set up and simple to insert, but it causes major problems later - particularly because it is very, very easy to get data which is not valid and as a result can;t be processed when it is needed - but that could be six months after the data was entered, when it's too late to work out exactly what the user intended.

Change your DB, change your software inserting values, and let presentation formatting be done at the time of presentation. Anything else is just propagating a problem further and further down the line and complicating software to the point it isn't worth maintaining.
 
Share this answer
 
Comments
CPallini 11-Jun-15 4:08am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900