Home » SQL & PL/SQL » SQL & PL/SQL » how to get the date range (merged)
how to get the date range (merged) [message #354696] Mon, 20 October 2008 21:34 Go to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
Hello Everyone Razz

I have a problem to define the date range. Firstly, this is my sql statement

Quote:
define date_start = '20080801';
define date_end = '20080901';

select hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), genesis_port, instance_name, api_name, sum(total_time), max(max_time), min(min_time), (sum(total_time)/sum(count)), sum(count)
from gen_api_performance_daily
where to_char(statistics_date,'YYYYMMDD') between &date_start and &date_end
group by hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), genesis_port, instance_name, api_name;




i have defined date_start as 20080801 and date_end as 20080901. So that is mean the statistics_date month is equal to the previous month. My problem is however, how will i get the date_start and date_end values? In my sql samples, they are still hardcoded. I cannot hardcode the values for date_start and date_end it in the script. The script should be able to know how to get the date range for the previous month, or the previous year. Any ideas?
Re: how to get the date range [message #354705 is a reply to message #354696] Mon, 20 October 2008 22:49 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
I have a union query that combines the results of several queries.
Each of these queries has a condition to extract the row where the
date is between 1/1/08 and 1/31/08. Each month when I run this I have
to do a find and replace to change the date range. Is there a way to
declare a date variable and reference that in the select statement
instead of the literal date?

For example
instead of between 1/1/08 and 1/31/08

it would be something like...

startDate = 1/1/08
endDate = 1/31/08

statement = between startdate and enddate

Thanks in advance
Re: how to get the date range [message #354713 is a reply to message #354696] Mon, 20 October 2008 23:26 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> alter session set nls_date_format='DD/MM/YYYY';

Session altered.

SQL> select sysdate,
  2         trunc(add_months(sysdate,-1),'month') start_date,
  3         trunc(sysdate,'month')-1 end_date
  4  from dual;
SYSDATE    START_DATE END_DATE
---------- ---------- ----------
21/10/2008 01/09/2008 30/09/2008

1 row selected.

Regards
Michel
Re: how to get the date range [message #354748 is a reply to message #354696] Tue, 21 October 2008 01:58 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
not sure how to change my statement above...

Re: how to get the date range [message #354756 is a reply to message #354748] Tue, 21 October 2008 02:38 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Try it and come back.
Before please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter).
Use the "Preview Message" button to verify.

Regards
Michel
Re: how to get the date range [message #354766 is a reply to message #354696] Tue, 21 October 2008 03:07 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
My problem is however, how will i get the date_start and date_end values? In my sql samples, they are still hardcoded. I cannot hardcode the values for date_start and date_end it in the script. The script should be able to know how to get the date range for the previous month, or the previous year. Any ideas?
Re: how to get the date range [message #354768 is a reply to message #354766] Tue, 21 October 2008 03:17 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@ejoeyz_85,

Please explain what you didn't understand from the solution posted by Michel?

Michel's Solution

SQL> alter session set nls_date_format='DD/MM/YYYY';

Session altered.

SQL> select sysdate,
  2         trunc(add_months(sysdate,-1),'month') start_date,
  3         trunc(sysdate,'month')-1 end_date
  4  from dual;
SYSDATE    START_DATE END_DATE
---------- ---------- ----------
21/10/2008 01/09/2008 30/09/2008

1 row selected.



There is no "hard-coded" value here.

Regards,
Jo
Re: how to get the date range [message #354770 is a reply to message #354696] Tue, 21 October 2008 03:20 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
How to convert it into my statement?? Because i have no idea of using this statement Sad

Re: how to get the date range [message #354774 is a reply to message #354766] Tue, 21 October 2008 03:26 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You need to explain your problem more clearly.
Are you just trying to write a query that can work out the start and end dates of the previous calendar month for itself, or are you looking to be able to enter dates into the query?

If it is the former, add an inline view into your FROM clause like
(SELECT trunc(add_months(sysdate,-1),'MON') start_date
      ,trunc(sysdate,'MON')-1              end_date
from dual)


This will let you refer to the start_date and end_date parameters in the SQL.

Alternatively, you could use the NEW_VALUE clause of the COLUMN efinition in SQL*Plus to populate a bind variable with results from a query like Michels.
Re: how to get the date range [message #354775 is a reply to message #354770] Tue, 21 October 2008 03:30 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@ejoeyz_85,

All I can provide is some links to the Date Functions used by Michel to help you understand what he is trying:

ADD_MONTHS Function
TRUNC Functions (with Dates)
Sysdate Function

Understand them and try a few queries yourself.

Hope this helps.

Regards,
Jo
Re: how to get the date range [message #354781 is a reply to message #354774] Tue, 21 October 2008 03:49 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
Yes yes... i am trying to write a query that can work out the start and end dates of the previous calendar month for itself..

I have a union query that combines the results of several queries.
Each of these queries has a condition to extract the row where the
date is between start_date and end_date. Each month when I run this I have to do a find and replace to change the date range. Is there a way to declare a date variable and reference that in the select statement instead of the literal date?


How to combine statement below and with my sql statement?

Quote:
SQL> select sysdate,
2 trunc(add_months(sysdate,-1),'month') start_date,
3 trunc(sysdate,'month')-1 end_date
4 from dual;
SYSDATE START_DATE END_DATE
---------- ---------- ----------
21/10/2008 01/09/2008 30/09/2008

1 row selected.



Quote:
select hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), genesis_port, instance_name, api_name, sum(total_time), max(max_time), min(min_time), (sum(total_time)/sum(count)), sum(count)
from gen_api_performance_daily
where to_char(statistics_date,'YYYYMMDD') between &date_start and &date_end
group by hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), genesis_port, instance_name, api_name;



table of gen_api_performance_daily :

Quote:
SQL> desc gen_api_performance_daily
Name Null? Type
----------------------------------------- -------- ----------------------------
HOSTNAME NOT NULL VARCHAR2(32)
STATISTICS_DATE NOT NULL DATE
GENESIS_PORT NOT NULL NUMBER
INSTANCE_NAME NOT NULL VARCHAR2(64)
API_NAME NOT NULL VARCHAR2(128)
TOTAL_TIME NUMBER
MAX_TIME NUMBER
MIN_TIME NUMBER
AVERAGE_TIME NUMBER
COUNT NUMBER




Re: how to get the date range [message #354787 is a reply to message #354781] Tue, 21 October 2008 04:39 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Michel Cadot wrote on Tue, 21 October 2008 09:38
Before please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter).
Use the "Preview Message" button to verify.


SQL> with
  2    dates as (
  3      select trunc(add_months(sysdate,-1),'month') start_date,
  4             trunc(sysdate,'month')-1 end_date
  5      from dual
  6    )
  7  select table_name
  8  from dba_tables, dates
  9  where last_analyzed between start_date and end_date
 10  /

no rows selected

Do you understand how to use it now?

Regards
Michel

Re: how to get the date range [message #354895 is a reply to message #354696] Tue, 21 October 2008 21:40 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
So i tried this statement :

Quote:

with
statistics_date as (
select trunc(add_months(sysdate,-1),'month') date_start, trunc(sysdate,'month')-1 date_end
from dual)

select hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), genesis_port, instance_name,
api_name, sum(total_time), max(max_time), min(min_time), (sum(total_time)/sum(count)), sum(count)
from gen_api_performance_daily
where to_char(statistics_date,'YYYYMMDD') between &date_start and &date_end
group by hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), genesis_port, instance_name, api_name;



and i got this result :

Quote:
old 1: select hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), genesis_port, instance_name,
new 1: select hostname, to_char(to_date(20080802, 'YYYYMMDD') , 'YYYY'), to_char(to_date(20080802, 'YYYYMMDD') , 'MM'), genesis_port, instance_name,
old 4: where to_char(statistics_date,'YYYYMMDD') between &date_start and &date_end
new 4: where to_char(statistics_date,'YYYYMMDD') between 20080802 and 20080902
old 5: group by hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), genesis_port, instance_name, api_name
new 5: group by hostname, to_char(to_date(20080802, 'YYYYMMDD') , 'YYYY'), to_char(to_date(20080802, 'YYYYMMDD') , 'MM'), genesis_port, instance_name, api_name
rows will be truncated

rows will be truncated

rows will be truncated

rows will be truncated

rows will be truncated

rows will be truncated


HOSTNAME TO_C TO GENESIS_PORT INSTANCE_NAME
-------------------------------- ---- -- ------------ --------------------------
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40011 MatlMgr

HOSTNAME TO_C TO GENESIS_PORT INSTANCE_NAME
-------------------------------- ---- -- ------------ --------------------------
10.228.51.41 2008 08 40011 MatlMgr
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office

HOSTNAME TO_C TO GENESIS_PORT INSTANCE_NAME
-------------------------------- ---- -- ------------ --------------------------
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office
10.228.51.41 2008 08 40019 MatlMgr_Office

...................

3627 rows selected.


Commit complete.




what does it mean?
Re: how to get the date range [message #354900 is a reply to message #354696] Tue, 21 October 2008 22:57 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Do proper format and use Code tag instead of Quotes tag.

Thumbs Up
Rajuvan.
Re: how to get the date range [message #354901 is a reply to message #354781] Tue, 21 October 2008 23:00 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

ejoeyz_85 wrote on Tue, 21 October 2008 08:49

How to combine statement below and with my sql statement?



change
&start_date with trunc(add_months(sysdate,-1),'month')
&end_date with trunc(sysdate,'month')-1
in your code.
Re: how to get the date range [message #354982 is a reply to message #354901] Wed, 22 October 2008 02:20 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Pl;us, you have to acutall include the Statistics_date data source in the FROM clause
Re: how to get the date range [message #354984 is a reply to message #354696] Wed, 22 October 2008 02:27 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Quote:
where to_char(statistics_date,'YYYYMMDD') between &date_start and &date_end


statistics_date is not a field . It should be table .
statistics_dat.date_start and statistics_date.date_end are the fields in your case.

[ Ohoh . do u have such field already ? Sad ]

Smile
Rajuvan.

[Updated on: Wed, 22 October 2008 02:29]

Report message to a moderator

Re: how to get the date range [message #354988 is a reply to message #354901] Wed, 22 October 2008 02:32 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
mency wrote on Tue, 21 October 2008 12:00

Quote:
change
&start_date with trunc(add_months(sysdate,-1),'month')
&end_date with trunc(sysdate,'month')-1
in your code.


should be like this?

with
  dates as (
  select [B]&date_start with trunc(add_months(sysdate,-1),'month'), 
&date_end with trunc(sysdate,'month')-1[/B]
  from dual)
		
select hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), 
to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), 
genesis_port, instance_name,
       api_name, sum(total_time), max(max_time), 
min(min_time), (sum(total_time)/sum(count)), sum(count)
  from gen_api_performance_daily, dates
 where to_char(statistics_date,'YYYYMMDD') between &date_start and &date_end 
 group by hostname, to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY'), 
to_char(to_date(&date_start, 'YYYYMMDD') , 'MM'), 
genesis_port, instance_name, api_name;

[Updated on: Wed, 22 October 2008 02:34] by Moderator

Report message to a moderator

Re: how to get the date range [message #354990 is a reply to message #354988] Wed, 22 October 2008 02:35 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I think you should investigate some time in SQL Reference instead of trying to find some valid syntax by trial and error.

Regards
Michel
Re: how to get the date range [message #354992 is a reply to message #354988] Wed, 22 October 2008 02:41 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

The date_start and date_end of your own query.
&date_start and &date_end 

Re: how to get the date range [message #355081 is a reply to message #354988] Wed, 22 October 2008 08:49 Go to previous messageGo to next message
joy_division
Messages: 4641
Registered: February 2005
Location: East Coast USA
Senior Member
ejoeyz_85 wrote on Wed, 22 October 2008 03:32

where to_char(statistics_date,'YYYYMMDD') between &date_start and &date_end
[/code]


This is invalid. Left side is a CHAR, right side will be treated as a number.
date format [message #355154 is a reply to message #354696] Wed, 22 October 2008 23:03 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
Hello everyone,

how to join the date range between &date_start and &date_end into this statement?

select to_char(to_date(&date_start, 'YYYYMMDD', 
&date_end, 'YYYYMMDD'), 'YYYY')


i tried but got error!
Re: date format [message #355157 is a reply to message #355154] Wed, 22 October 2008 23:08 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Why did you post it as new thread instead of posting here

Anyway wht do you mean by

Quote:
join the date range between &date_start and &date_end


Smile
Rajuvan.
Re: date format [message #355159 is a reply to message #355154] Wed, 22 October 2008 23:14 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@ejoeyz_85,

You really should learn TO_DATE Function

Check the number of parameters in your
to_date(&date_start, 'YYYYMMDD', 
&date_end, 'YYYYMMDD') 

?????

I didn't understand your requirement. I was just pointing out a syntax error in your query.

Regards,
Jo

[***Added:- Didn't See the thread being moved]

[Updated on: Wed, 22 October 2008 23:15]

Report message to a moderator

Re: how to get the date range (merged) [message #355161 is a reply to message #354696] Wed, 22 October 2008 23:22 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member

this is the original statement :
i defined a
$date_start = 20080901
$date_end = 20080930

select to_char(to_date(&date_start, 'YYYYMMDD') , 'YYYY')


so, after execute, at the column name should be:

to_char(to_date(20080901, 'YYYYMMDD') , 'YYYY')



so my question is can i combine the date_start and date_end so that i can get a column name like this:

to_char(to_date(&date_start, &date_end, 'YYYYMMDD') , 'YYYY')
Re: how to get the date range (merged) [message #355165 is a reply to message #355161] Wed, 22 October 2008 23:27 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
to_char(to_date(&date_start, &date_end, 'YYYYMMDD') , 'YYYY')

And what this wants to mean?

Regards
Michel
Re: how to get the date range (merged) [message #355167 is a reply to message #355165] Wed, 22 October 2008 23:31 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
the column_name should have &date_start and &date_end

Quote:
to_char(to_date(&date_start, &date_end, 'YYYYMMDD') , 'YYYY')


i want to display date start and also date end at the column name
Re: how to get the date range (merged) [message #355171 is a reply to message #354696] Thu, 23 October 2008 00:28 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

I think you are making the QUESTION more complex. so the answer.

Now Tell us ,

What is you are trying to do ? (SQL Query)
What are you getting as output ? ( with example)
What is the expected output ? ( with example)

Please Please Please use the CODE tag while replying .

Smile
Rajuvan.

Re: how to get the date range (merged) [message #355174 is a reply to message #355167] Thu, 23 October 2008 00:35 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
want to display date start and also date end at the column name

JRowbottom wrote on Tue, 21 October 2008 10:26
Alternatively, you could use the NEW_VALUE clause of the COLUMN efinition in SQL*Plus to populate a bind variable with results from a query like Michels.

Regards
Michel

Re: how to get the date range (merged) [message #355249 is a reply to message #354696] Thu, 23 October 2008 05:07 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
Below is to get date range between a month

trunc(add_months(sysdate,-1),'month') start_date,
trunc(sysdate,'month')-1 end_date



how to get date range between a year

start_date = 20080101
end_date = 20081231

help me?
Re: how to get the date range (merged) [message #355250 is a reply to message #354696] Thu, 23 October 2008 05:09 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
Below is to get date range between a month

trunc(add_months(sysdate,-1),'month') start_date,
trunc(sysdate,'month')-1 end_date



how to get date range between a year

start_date = 20080101
end_date = 20081231

help me?
Re: how to get the date range (merged) [message #355265 is a reply to message #355250] Thu, 23 October 2008 05:30 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What do you mean, a year always starts on January 1st and ends on December 31st.

Regards
Michel
Re: how to get the date range (merged) [message #355268 is a reply to message #354696] Thu, 23 October 2008 05:35 Go to previous messageGo to next message
ejoeyz_85
Messages: 30
Registered: October 2008
Member
yes yes a year always starts on January 1st and ends on December 31st. how to get date range between a year using trunc statement same as below? because there is no "hard-coded" value here. i want no hardcode value in my script

SQL> alter session set nls_date_format='DD/MM/YYYY';

Session altered.

SQL> select sysdate,
  2         trunc(add_months(sysdate,-1),'month') start_date,
  3         trunc(sysdate,'month')-1 end_date
  4  from dual;
SYSDATE    START_DATE END_DATE
---------- ---------- ----------
21/10/2008 01/09/2008 30/09/2008


1 row selected.




Re: how to get the date range (merged) [message #355269 is a reply to message #355268] Thu, 23 October 2008 05:39 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> select extract(year from sysdate) year from dual;
      YEAR
----------
      2008

1 row selected.

SQL> alter session set nls_date_format='DD-MON-YYYY';

Session altered.

SQL> select trunc(sysdate,'YEAR') from dual;
TRUNC(SYSDA
-----------
01-JAN-2008

1 row selected.

I let you post for the last day of the year.

Regards
Michel
Re: how to get the date range (merged) [message #355341 is a reply to message #354696] Thu, 23 October 2008 15:17 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
A couple of things

When you are comparing a date do NOT!!!!! convert it to a character string

2)I can't stand it anymore.

where statistics_date between trunc(add_months(sysdate,-1),'mon') and last_day(trunc(add_months(sysdate,-1)))
Previous Topic: SQL with CASE in Trigger
Next Topic: Selecting columns depending upon comparison of two other columns
Goto Forum:
  


Current Time: Wed Dec 07 03:10:17 CST 2016

Total time taken to generate the page: 0.07946 seconds