473,378 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

drop 0 from hour/minute

4
Hi

looping within python resources..., I did not find a way to drop the 0 from hours/minutes. In fact I'd like to simply calculate the number of seconds since midnight so I did something like:

Expand|Select|Wrap|Line Numbers
  1. int(eval(time.strftime("%H*3600 + %M*60 + %S" , time.localtime())))
but obviously, that's failing when minute/hour look like 0x. It should work on any OS

Cheers
Aug 27 '09 #1
1 1453
bvdet
2,851 Expert Mod 2GB
A straightforward way of calculating this would be to use the atributes of the time.struct_time object. Example:
Expand|Select|Wrap|Line Numbers
  1. >>> t = time.localtime()
  2. >>> t.tm_hour*3600+t.tm_min*60+t.tm_sec
  3. 40535
Aug 27 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark Jerzykowski | last post by:
Hi, I have a log table which contains the fields log_time (DATETIME) and session_id (VARCHAR). Using these 2 columns I want to be able to SELECT the number of users who have been online during...
1
by: Mark | last post by:
I have a textbox for Hour, a textbox for Minute, a textbox for AM/PM and an up button and down button to increment/decrement the values in the textboxes. I have the code to increment/decrement all...
2
by: James P. | last post by:
Hello, In my Access report, I have a minutes field in the detail line. How do I convert that minute to hour and minute. The problem for me now is if I take the minutes, say 75 divide by 60, it...
2
by: Water Cooler v2 | last post by:
What am I missing here. I bind a drop-down list in ASP.NET placed on a web form to a DataReader. The binding is done at run-time and not at design time. Here's the code I write to bind the list: ...
0
by: fhmm | last post by:
hellow everybody i need your help i have problem in counting the waiting time for a person for example if we need to count the waiting time for a person from which he has come to the time 15:30...
5
by: cssExp | last post by:
the problem is, i have a dynamic database driven site, each data is entered with year, week etc.. 2 months ago assuming I'll create sort option in future i put everything, i.e year, week, hour,...
1
by: rcamarda | last post by:
I have rows of data that have a datetime stamp. I need to find rows that have a datetime stamp within 10 seconds of the top of each hour. I started with datediff(s,getdate(),LeadDate) but I am...
1
by: George | last post by:
Hello........I have a problem adding up record entries with more than 24 hours when the fields are formatted as hour/minute (h:m). If the actual summed total of all records is greater than 24...
5
by: maury | last post by:
Hello, I have an SQL Server table with a (text) field in which there is a data value in this format: 200802290525 I need to build an update query the modifies this value subtracting 1 (one)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.