Page 1 of 1

to fetch current date-2 date records count only

PostPosted: Tue Nov 29, 2011 12:17 am
by rekhamf
Hi ,

Can you please let me know : How I can get the count for the particular date (from start timestamp till end timestamp) from the table ?

Rule :
=====
Current date -2 ( if todays date is dec 1st, then i need to get the count from the table for only the date nov 29th)

SELECT Count(Distinct (Emply number) FROM Employ table where
WHERE LOG_TS BETWEEN
(TIMESTAMP(CURRENT DATE- 02 days ,'00:00')-
AND (TIMESTAMP(CURRENT DATE - 02 DAYS,'00:00')- 1 MICROSECOND) WITH UR;

This returns no rows .
Can you please help on this ?

Re: to fetch current date-2 date records count only

PostPosted: Tue Nov 29, 2011 12:29 am
by Akatsukami
Please copy and paste the actual query using code tags to preserve formatting.

Re: to fetch current date-2 date records count only

PostPosted: Tue Nov 29, 2011 1:00 am
by rekhamf
I have this query .but i need someone to help with this condition :

SELECT Count(Distinct (Emply_number) FROM Employ table where
WHERE LOG_TS BETWEEN
(TIMESTAMP(CURRENT DATE- 02 days ,'00:00')-
AND (TIMESTAMP(CURRENT DATE - 02 DAYS,'00:00')- 1 MICROSECOND) WITH UR;

Re: to fetch current date-2 date records count only

PostPosted: Tue Nov 29, 2011 1:30 am
by NicC
Well, the condition is perfectly valid as it is - might not do what you want but you have not provided the information asked for in the format asked for - using code tags. (See the full editor.)

Re: to fetch current date-2 date records count only

PostPosted: Tue Nov 29, 2011 2:08 am
by rekhamf
SELECT Count(Distinct (Emply_number) FROM Employ table where
WHERE LOG_TS BETWEEN
(TIMESTAMP(CURRENT DATE- 02 days ,'00:00')-
AND (TIMESTAMP(CURRENT DATE - 02 DAYS,'00:00')- 1 MICROSECOND) WITH UR;


I have this query .but i need someone to help with this condition : for particular date ( current date-2) .I tried many scenarios for this,but not able to find the exact condition.

Re: to fetch current date-2 date records count only

PostPosted: Tue Nov 29, 2011 2:30 am
by rekhamf
WHERE LOG_TS BETWEEN                                   
              TIMESTAMP(CURRENT DATE - 2 DAYS ,'00:00')
       AND      TIMESTAMP(CURRENT DATE - 2 DAYS,'24:00')
       WITH UR;                                         



I have change the where condition in this query

Re: to fetch current date-2 date records count only

PostPosted: Tue Nov 29, 2011 2:30 am
by Akatsukami
rekhamf wrote:
SELECT Count(Distinct (Emply_number) FROM Employ table where
WHERE LOG_TS BETWEEN
(TIMESTAMP(CURRENT DATE- 02 days ,'00:00')-
AND (TIMESTAMP(CURRENT DATE - 02 DAYS,'00:00')- 1 MICROSECOND) WITH UR;


I have this query .but i need someone to help with this condition : for particular date ( current date-2) .I tried many scenarios for this,but not able to find the exact condition.

Well, your "query" has two sets of unbalanced parentheses, an improperly repeated keyword, an typographical error, and an apparently missing duration, any of which would prevent it for running; therefore, this isn't the SQL that you're actually using. Since we can't literally hold your feet to the fire to get the truth out of you, we can't help and I won't try.

Re: to fetch current date-2 date records count only

PostPosted: Tue Nov 29, 2011 7:49 pm
by GuyC
I must say this looks very much like the query I gave you yesterday :
ibm-cobol/topic6695.html

Re: to fetch current date-2 date records count only

PostPosted: Tue Nov 29, 2011 10:58 pm
by rekhamf
Thanks Guyc.I tried with same model of query for this .its working .you helped me lot.Thank you so much