Oracle DataBase DateFormat


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Oracle DataBase DateFormat
# 1  
Old 03-08-2012
Oracle DataBase DateFormat

I am currently writing a script in AIX
I connected to the database using SQL *PLUS
I need to retrive data of Number of rows inserted today in the table(TABLE_NAME) which has column DATETIME(DDMMYYYY)

I tried using

Code:
select TO_CHAR(sysdate, 'DDMMYYYY') CHRDATE from dual
select count (*) from TABLE_NAME
where trunc(DATETIME) = trunc(CHRDATE);


HTML Code:
sysdate is in format MM/DD/YYYY
Thanks in advance
# 2  
Old 03-08-2012
Is the column DATETIME of datatype varchar2 or date?
If it is varchar2 the trunc function is not needed (without further parameters it cuts off the time component of values of datatype date):
Code:
select count(*) 
  from table_name
 where datetime = to_char(sysdate,'DDMMYYYY');

# 3  
Old 03-08-2012
Try like...
Code:
select hiredate from emp1 where trunc(hiredate)=trunc(sysdate)

Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Identify a specific environment Oracle variable to connect a remote Oracle database ?

Good evening I nned your help pls, In an unix server i want to connect to a remote oracle databse server by sqlplus. I tried to find out the user/passwd and service name by env variable and all Ive got is this: ORACLE_SID_REPCOL=SCL_REPCOL ORACLE_SID=xmeta ORACLE_SID_TOL=SCL_PROTOLCOL... (2 Replies)
Discussion started by: alexcol
2 Replies

2. UNIX and Linux Applications

Oracle database recovery

Is there a way to recover Oracle database in x86 server from broken sparc server (Solaris10)? (9 Replies)
Discussion started by: orange47
9 Replies

3. UNIX and Linux Applications

Moving Oracle database

how does one move Oracle database to new OS? Does Oracle need to be the same version as old one? (6 Replies)
Discussion started by: orange47
6 Replies

4. Solaris

Can't create database after Oracle Database installation

I installed Oracle 10 software on Solaris 11 Express, everything was fine execpt I can't create database using dbca.rsp file. I populated file with following options. OPERATION_TYPE = "createDatabase" GDBNAME = "solaris_user.domain.com" SID = "solaris_user" TEMPLATENAME = "General... (0 Replies)
Discussion started by: solaris_user
0 Replies

5. Programming

Oracle Database Query

How can i modify the below to search for the things i'm looking for during a certain time frame? select Node, NodeAlias, Summary, Tally, AlertKey, AlertGroup, Manager, Agent from mrtg_alerts where LastOccurrence > '5-Dec-2010' order by Manager desc; In this particular case, this query is... (3 Replies)
Discussion started by: SkySmart
3 Replies

6. Shell Programming and Scripting

Connecting to oracle database

Hai i want to connect to oracle database from user input and create a view. ${ECHO} "Debut Creating View" ${ECHO} "Please Enter the User Name:" read user_name ${ECHO} "Please Enter the Connection String:" read con_string ${ECHO} "Please Enter the Password:" read pwd... (3 Replies)
Discussion started by: shenthil76
3 Replies
Login or Register to Ask a Question