cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Statement for fetching the current day records in JDBC sender communication channel

Bhargavakrishna
Active Contributor
0 Kudos

Hi Experts,

We have a requirement where i need to fetch the current day records from the SQL SERVER 2008. for that i have to write a query in such a way that. it should only fetch the current date records.

Fields to be fetched from the SQL sever are

empCodeEventDateEvent ID
1456628-01-2012 11:45:54:456616
1456729-01-2012 12:10:45:546617
1456831-01-2012 10:45::56:845616
1456931-01-2012 12:55:32:256216
1457001-02-2012 09:32:21:121520

Data format for the Event date is : YYYY-MM-DD HH:MM:SS:MS. there is no separate field for the Date.

the other condition is we should only fetch the EventID's which is equal to 616 or 617

so can someone help me with the query.



Accepted Solutions (0)

Answers (3)

Answers (3)

Bhargavakrishna
Active Contributor
0 Kudos

thank u all...

Former Member
0 Kudos

Dear Bhargava,

You may try the SQL below as an alternative to Venkat's suggestion:

SELECT * FROM [table] WHERE EventDate LIKE DATE_FORMAT (NOW(), '%d-%m-%Y %') AND EventId IN ('616', '617')

Regards,

Koen

Former Member
0 Kudos

Hi Bhargava,

Try the below.

select * from tablename WHERE CAST(CONVERT(VARCHAR,expirydate,101) AS DATETIME) <= CAST(CONVERT(VARCHAR,GETDATE(),101) AS DATETIME) AND (EventID='616' OR EventID='617')

Execute the above query first in sql server and check whether it is properly working or not .We don't have sql server ,so i haven't checked it.

Regards

Venkat